Skip to content

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

Closed

Description

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions