.net-corenunitdotnet-test

Pass multiple tests names in "dotnet test --filter" option


I am trying to rerun failed tests using dotnet test command. I want to pass a list of failed tests from a file created during test run. I can't seem to get the '&' operator syntax right for the "--filter" option. I am able to pass only one test name per run. Example: dotnet test --filter "FullyQualifiedName~TestOne1 & FullyQualifiedName~TestOne2"


Solution

  • Think of the text you write into the filter like evaluating a boolean. None of your tests' FullyQualifiedName can be TestOne1 AND TestOne2 at the same time.

    Try using the | (OR) operator instead like this:

    dotnet test --filter "FullyQualifiedName~TestOne1 | FullyQualifiedName~TestOne2"

    This way your test's FullyQualifiedName can be like TestOne1 OR TestOne2.

    Source: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details