question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Explicit tests executed when running with dotnet test and a filter

See original GitHub issue

Hello

The tests marked with [Explicit] seems to be executed since 4.0.0 when trying to run test from the command line using --filter

dotnet test TestProject1.sln --filter TestProject1

<TargetFramework>net5.0</TargetFramework>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />

Repro: TestProject1.zip

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
OsirisTerjecommented, Nov 9, 2021

@runehalfdan Thanks! It seems you’re right in your case. The case is different from the one reported here, so I’ll move this into a new issue.

0reactions
runehalfdancommented, Nov 9, 2021

I have a similar issue, but I use NUnit-filters ‘cat!=FOO’

Using the enclosed test-project here, and adding some categorized filters, Explicit tests are executed Running dotnet test TestProject1.sln -v:n --logger="Console;verbosity=detailed" -- NUnit.Where="cat!=FOO" products

Running selected tests in C:\source\rune\NUnitTestProject1\TestProject1\bin\Debug\net5.0\TestProject1.dll
   NUnit3TestExecutor discovered 2 of 2 NUnit test cases using Current Discovery mode, Non-Explicit run
NUnit Adapter 4.1.0.0: Test execution complete
  Failed Test1 [30 ms]
  Stack Trace:
     at TestProject1.Tests.Test1() in C:\source\rune\NUnitTestProject1\TestProject1\UnitTest1.cs:line 12

  Passed TestBar [1 ms]

Adding ‘cat!=Explicit’ does not help

(btw, using legacy discovery does help, and we will use that for now)

All tests:

[Test]
[Explicit]
public void Test1()
{
	Assert.Fail();
}

[Test]
[Category("FOO")]
public void TestFoo()
{
    Assert.Pass();
}

[Test]
[Category("BAR")]
public void TestBar()
{
    Assert.Pass();
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Running tests marked as [Explicit] with dotnet test
1 Answer. As per this Github issue this is actually a known bug with NUnit3TestAdapter where tests marked as [Explicit] would not execute...
Read more >
Run selected unit tests - .NET
NET Core, you can use a filter expression to run selected tests. This article demonstrates how to filter tests. The examples use dotnet...
Read more >
Explicit
The Explicit attribute causes a test or test fixture to be skipped unless it is explicitly selected for running. The test or fixture...
Read more >
Improve your pipeline maintainability with test categories in ...
I have worked in a team where xUnit was used as the testing framework in ... Run all unit tests dotnet test --filter...
Read more >
Running and Filtering Tests with the .NET Core Command ...
Assuming we have two test projects (as follows), the tests contained within these test projects can be executed with the dotnet test command....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found