Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run specific tests using dotnet test?

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?

like image 312
Nate Barbettini Avatar asked Jun 10 '16 15:06

Nate Barbettini


People also ask

How do I run a specific test in Visual Studio?

If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.


1 Answers

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

like image 149
andrecarlucci Avatar answered Sep 21 '22 17:09

andrecarlucci