How do I run specific tests using dotnet test?

xunit.net.Net Core.Net Core-Rc2Xunit2

xunit.net Problem Overview


I have a large test suite in a .NET Core project. I can use the Test Explorer window to select a few tests to run.

I can also run the whole test suite on the command line with dotnet test. Is there a way to run only one (or a few) tests on the command line?

xunit.net Solutions


Solution 1 - xunit.net

With the dotnet version 1.0.0, you have to use the --filter option:

You can filter by DisplayName, FullyQualifiedName and Traits.

Ex:

dotnet test --filter "FullyQualifiedName=YourNamespace.TestClass1.Test1"

Also, these operators are allowed: =, != and ~ (contains).

More info here: docs

Solution 2 - xunit.net

Since this question is tagged with xUnit, the command for the dotnet xUnit CLI command is as follows:

dotnet xunit -method FullyQualifiedName

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNate BarbettiniView Question on Stackoverflow
Solution 1 - xunit.netandrecarlucciView Answer on Stackoverflow
Solution 2 - xunit.netGeorgDanglView Answer on Stackoverflow