Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Core 2.0: Default test case filter fails #730

Closed
natemcmaster opened this issue Apr 17, 2017 · 2 comments
Closed

.NET Core 2.0: Default test case filter fails #730

natemcmaster opened this issue Apr 17, 2017 · 2 comments

Comments

@natemcmaster
Copy link
Contributor

In #555 @smadala added this feature:

  • Convert dotnet test --filter "ABC" to dotnet test --filter "FullyQualifiedName~ABC".

This feature fails on .NET Core 2.0.

Steps to reproduce

  1. Download latest .NET Core 2.0 CLI: https://github.com/dotnet/cli
  2. Double check dotnet --version. You may need to add global.json to workaround https://github.com/dotnet/core-setup/issues/1664.
{
  "sdk": { "version": "2.0.0-preview1-005783"}
}
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
    <IsPackable>false</IsPackable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="xunit" Version="2.2.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
  </ItemGroup>
</Project>
using Xunit;

namespace Filter
{
    public class UnitTest
    {
        [Fact]
        public void Test2()
        {
            Assert.False(true);
        }

        [Fact]
        public void Test1()
        {
        }
    }
}
  1. dotnet restore and dotnet test --filter Test1

Expected behavior

Only runs Filter.UnitTest.Test1 on .NET Core 2.0 and .NET Framework 4.6

Actual behavior

Runs Filter.UnitTest.Test1 on .NET Framework 4.6
Fails on .NET Core 2.0

Build started, please wait...
Build completed.

Test run for C:\tmp\filter\bin\Debug\netcoreapp2.0\filter.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
[xUnit.net 00:00:00.4061876]   Discovering: filter
[xUnit.net 00:00:00.5071793]   Discovered:  filter
[xUnit.net 00:00:00.5165779] filter: Exception filtering tests: Incorrect format for TestCaseFilter Error: Invalid Condition 'Test1'. Specify the correct format and try again. Note that the incorrect format can lead to no test getting executed.
[xUnit.net 00:00:00.5387654]   Starting:    filter
[xUnit.net 00:00:00.5752972]   Finished:    filter
No test is available in C:\tmp\filter\bin\Debug\netcoreapp2.0\filter.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.



Test run for C:\tmp\filter\bin\Debug\net46\filter.dll(.NETFramework,Version=v4.6)
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
[xUnit.net 00:00:00.2819846]   Discovering: filter
[xUnit.net 00:00:00.4161181]   Discovered:  filter
[xUnit.net 00:00:00.6782466]   Starting:    filter
[xUnit.net 00:00:00.8520016]   Finished:    filter

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1.2302 Seconds

Environment

dotnet --info:

.NET Command Line Tools (2.0.0-preview1-005783)

Product Information:
 Version:            2.0.0-preview1-005783
 Commit SHA-1 hash:  8bd15c7ec0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Users\namc\AppData\Local\Microsoft\dotnet\sdk\2.0.0-preview1-005783\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0-preview1-001967-00
  Build    : fa25acec41a87ce36b3ea61273d4798eb0a2486f
@smadala
Copy link
Contributor

smadala commented Apr 17, 2017

@natemcmaster this feature for netcore tests need latest testhost which ship with Microsoft.NET.Test.Sdk: 15.1.0-preview-20170414-10 you can get it from nuget source https://dotnet.myget.org/F/vstest/api/v3/index.json.

@natemcmaster
Copy link
Contributor Author

Confirmed this bug doesn't repro when upgrading to 15.1. Thanks @smadala.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants