nunit / nunit3-vs-adapter

NUnit 3.0 Visual Studio test adapter for use under VS 2012 or later
https://nunit.org
MIT License
203 stars 105 forks source link

dotnet test -- NUnit.Where works but dotnet test --list-tests -- NUnit.Where does not #1183

Closed pluma9 closed 3 months ago

pluma9 commented 3 months ago

But dotnet test --list-tests -- NUnit.Where="name=~Foo" outputs 3 tests:

The following Tests are available:
    Bar
    Foo
    FooBar

Expectation: --list-tests should output only 2 tests.

The Tests class:

public class Tests
{
    [Test] public void Foo() { Assert.Pass(); }
    [Test] public void Bar() { Assert.Pass(); }
    [Test] public void FooBar() { Assert.Pass(); }
}

csproj:


<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>

    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="coverlet.collector" Version="6.0.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
    <PackageReference Include="NUnit" Version="4.1.0" />
    <PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
  </ItemGroup>

  <ItemGroup>
    <Using Include="NUnit.Framework" />
  </ItemGroup>

</Project>
OsirisTerje commented 3 months ago

The --list-tests command is only using the Discovery section for tests. No filters work with that command , not the where command, and not the dotnet --filter <selection statement>.

For normal execution, using the Execution section , which applies the filters.

I don't think we will change this behavior.