dotnet-test - .NET test driver used to execute unit tests.


dotnet test [<PROJECT>] [-s|--settings] [-t|--list-tests] [--filter] [-a|--test-adapter-path] [-l|--logger] [-c|--configuration] [-f|--framework] [-o|--output] [-d|--diag] [--no-build] [-v|--verbosity] [-h|--help]


The dotnet test command is used to execute unit tests in a given project. Unit tests are console application projects that have dependencies on the unit test framework (for example, MSTest, NUnit, or xUnit) and the dotnet test runner for the unit testing framework. These are packaged as NuGet packages and are restored as ordinary dependencies for the project.

Test projects also must specify the test runner. This is specified using an ordinary <PackageReference> element, as seen in the following sample project file:

<Project Sdk="Microsoft.NET.Sdk">


    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="xunit" Version="2.2.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />




Specifies a path to the test project. If omitted, it defaults to current directory.


Prints out a short help for the command.

-s|--settings <SETTINGS_FILE>

Settings to use when running tests.


List all of the discovered tests in the current project.

--filter <EXPRESSION>

Filters out tests in the current project using the given expression. For more information on filtering support, see Running selective unit tests in Visual Studio using TestCaseFilter.

-a|--test-adapter-path <PATH_TO_ADAPTER>

Use the custom test adapters from the specified path in the test run.

-l|--logger <LoggerUri/FriendlyName>

Specifies a logger for test results.

-c|--configuration <CONFIGURATION>

Configuration under which to build. The default value is Debug, but your project's configuration could override this default SDK setting.

-f|--framework <FRAMEWORK>

Looks for test binaries for a specific framework.

-o|--output <OUTPUT_DIRECTORY>

Directory in which to find the binaries to run.


Enables diagnostic mode for the test platform and write diagnostic messages to the specified file.


Does not build the test project prior to running it.

-v|--verbosity <LEVEL>

Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].


Run the tests in the project in the current directory:

dotnet test

Run the tests in the test1 project:

dotnet test ~/projects/test1/test1.csproj

See also