How do I run specific tests using dotnet test?

Nate Barbettini picture Nate Barbettini · Jun 10, 2016 · Viewed 16.7k times · Source

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?

Answer

andrecarlucci picture andrecarlucci · Mar 14, 2017

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