dotnet-test(1)
okay bestie, real talk β this is the manual page for dotnet-test(1), straight out of the .NET Documentation π«Ά she's long, she's iconic, and she comes in four parts, so buckle up π
β¨ NAME β¨
dotnet-test β the .NET test driver, aka the girl you call when you need to actually execute your unit tests π
π DESCRIPTION π
Okay so here's the tea: the dotnet test command builds your solution and then runs the tests using either VSTest or Microsoft Testing Platform (MTP). Wanna turn on MTP? You gotta specify the test runner in your global.json file, no cap.
Some examples of how to specify the test runner in global.json:
{
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
{
"test": {
"runner": "VSTest"
}
}
β οΈ Heads up bestie: thedotnet testexperience for MTP is only supported inMicrosoft.Testing.Platformversion 1.7 and later. Don't come for me, that's just what the docs say π
π‘ TIP: for conceptual documentation aboutdotnet test, see Testing withdotnet test.
π¦ VSTest and Microsoft.Testing.Platform (MTP) π¦
(no body text here bestie, the docs left this one as just a heading β she's mysterious π)
πΈ dotnet test with VSTest πΈ
(same situation, just a heading, nothing under her π«Ά)
π SYNOPSIS π
dotnet test [<PROJECT> | <SOLUTION> | <DIRECTORY> | <DLL> | <EXE>]
[--test-adapter-path <ADAPTER_PATH>]
[-a|--arch <ARCHITECTURE>]
[--artifacts-path <ARTIFACTS_DIR>]
[--blame]
[--blame-crash]
[--blame-crash-dump-type <DUMP_TYPE>]
[--blame-crash-collect-always]
[--blame-hang]
[--blame-hang-dump-type <DUMP_TYPE>]
[--blame-hang-timeout <TIMESPAN>]
[-c|--configuration <CONFIGURATION>]
[--collect <DATA_COLLECTOR_NAME>]
[-d|--diag <LOG_FILE>]
[--disable-build-servers]
[-f|--framework <FRAMEWORK>]
[-e|--environment <NAME="VALUE">]
[--filter <EXPRESSION>]
[--interactive]
[-l|--logger <LOGGER>]
[--no-build]
[--nologo]
[--no-restore]
[-o|--output <OUTPUT_DIRECTORY>]
[--os <OS>]
[--results-directory <RESULTS_DIR>]
[-r|--runtime <RUNTIME_IDENTIFIER>]
[-s|--settings <SETTINGS_FILE>]
[-t|--list-tests]
[--tl:[auto|on|off]]
[-v|--verbosity <LEVEL>]
[<args>...]
[[--] <RunSettings arguments>]
dotnet test -h|--help
π₯ DESCRIPTION π₯
The dotnet test command is the one you use to execute unit tests in a given solution. What she does: she builds the solution, then runs a test host application for each test project in the solution using VSTest. That test host runs your tests in the given project using a test framework β for example: MSTest, NUnit, or xUnit β and reports the success or failure of each test. If every single test is successful, the test runner returns 0 as an exit code; otherwise, if any test fails, she returns 1. It's giving pass/fail, periodt.
πdotnet testwas originally designed to support only VSTest-based test projects. Recent versions of the test frameworks are adding support forMicrosoft.Testing.Platform. This alternative test platform is more lightweight and faster than VSTest and supportsdotnet testwith different command line options. For more information, seeMicrosoft.Testing.Platform.
For multi-targeted projects, tests are run for each targeted framework. The test host and the unit test framework are packaged as NuGet packages and are restored as ordinary dependencies for the project. Starting with the .NET 9 SDK, these tests are run in parallel by default π₯. Wanna disable parallel execution? Set the TestTfmsInParallel MSBuild property to false. For more information, see Run tests in parallel and the example command line later in this article.
Test projects specify the test runner using an ordinary <PackageReference> element, as seen in the following sample project file:
[!code-xmlXUnit Basic Template]
Where Microsoft.NET.Test.Sdk is the test host, xunit is the test framework. And xunit.runner.visualstudio is a test adapter, which allows the xUnit framework to work with the test host. Slay, that's the whole ecosystem π§
π Implicit restore π
You don't have to run dotnet restore because it's run implicitly by all commands that require a restore to occur, such as dotnet new, dotnet build, dotnet run, dotnet test, dotnet publish, and dotnet pack. To disable implicit restore, use the --no-restore option.
The dotnet restore command is still useful in certain scenarios where explicitly restoring makes sense, such as continuous integration builds in Azure DevOps Services or in build systems that need to explicitly control when the restore occurs.
For information about how to manage NuGet feeds, see the dotnet restore documentation.
π Workload manifest downloads π
When you run this command, it initiates an asynchronous background download of advertising manifests for workloads. If the download is still running when this command finishes, the download is stopped. For more information, see Advertising manifests.
π ARGUMENTS π
PROJECT | SOLUTION | DIRECTORY | DLL | EXE- Path to the test project.
- Path to the solution.
- Path to a directory that contains a project or a solution.
- Path to a test project
.dllfile. - Path to a test project
.exefile.
If not specified, the effect is the same as using the DIRECTORY argument to specify the current directory.
π OPTIONS π
π¨ WARNING: breaking changes in options: - Starting in .NET 7: switch-ato alias--archinstead of--test-adapter-path- Starting in .NET 7: switch-rto alias--runtimeinstead of--results-directory
π¨ WARNING: when usingMicrosoft.Testing.Platform, please refer todotnet testintegration for the supported options. As a rule of thumbs, every option non-related to testing is supported while every testing-related option is not supported as-is. iykyk π
--test-adapter-path <ADAPTER_PATH>β Path to a directory to be searched for additional test adapters. Only.dllfiles with suffix.TestAdapter.dllare inspected. If not specified, the directory of the test.dllis searched. Short form-aavailable in .NET SDK versions earlier than 7.--arch <ARCHITECTURE>β Specifies the target architecture. This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on awin-x64machine, specifying--arch x86sets the RID towin-x86. If you use this option, don't use the-r|--runtimeoption. Available since .NET 6 Preview 7.--artifacts-path <ARTIFACTS_DIR>β All build output files from the executed command will go in subfolders under the specified path, separated by project. For more information see Artifacts Output Layout. Available since .NET 8 SDK.--blameβ Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash. When a crash is detected, it creates a sequence file inTestResults/<Guid>/<Guid>_Sequence.xmlthat captures the order of tests that were run before the crash. This option does not create a memory dump and is not helpful when the test is hanging. π--blame-crash(Available since .NET 5.0 SDK) β Runs the tests in blame mode and collects a crash dump when the test host exits unexpectedly. This option depends on the version of .NET used, the type of error, and the operating system. For exceptions in managed code, a dump will be automatically collected on .NET 5.0 and later versions. It will generate a dump fortesthostor any child process that also ran on .NET 5.0 and crashed. Crashes in native code will not generate a dump. This option works on Windows, macOS, and Linux. Crash dumps in native code, or when using .NET Core 3.1 or earlier versions, can only be collected on Windows, by using Procdump. A directory that containsprocdump.exeandprocdump64.exemust be in thePATHorPROCDUMP_PATHenvironment variable. Download the tools. Implies--blame. To collect a crash dump from a native application running on .NET 5.0 or later, the usage of Procdump can be forced by setting theVSTEST_DUMP_FORCEPROCDUMPenvironment variable to1.--blame-crash-dump-type <DUMP_TYPE>(Available since .NET 5.0 SDK) β The type of crash dump to be collected. Supported dump types arefull(default), andmini. Implies--blame-crash.--blame-crash-collect-always(Available since .NET 5.0 SDK) β Collects a crash dump on expected as well as unexpected test host exit.--blame-hang(Available since .NET 5.0 SDK) β Run the tests in blame mode and collects a hang dump when a test exceeds the given timeout.--blame-hang-dump-type <DUMP_TYPE>(Available since .NET 5.0 SDK) β The type of crash dump to be collected. It should befull,mini, ornone. Whennoneis specified, test host is terminated on timeout, but no dump is collected. Implies--blame-hang.--blame-hang-timeout <TIMESPAN>(Available since .NET 5.0 SDK) β Per-test timeout, after which a hang dump is triggered and the test host process and all of its child processes are dumped and terminated. The timeout value is specified in one of the following formats:1.5h,1.5hour,1.5hours90m,90min,90minute,90minutes5400s,5400sec,5400second,5400seconds5400000ms,5400000mil,5400000millisecond,5400000millisecondsWhen no unit is used (for example,5400000), the value is assumed to be in milliseconds. When used together with data driven tests, the timeout behavior depends on the test adapter used. For xUnit, NUnit. and MSTest 2.2.4+, the timeout is renewed after every test case. For MSTest before version 2.2.4, the timeout is used for all test cases. This option is supported on Windows withnetcoreapp2.1and later, on Linux withnetcoreapp3.1and later, and on macOS withnet5.0or later. Implies--blameand--blame-hang.
-c|--configuration <CONFIGURATION>β Defines the build configuration. The default for most projects isDebug, but you can override the build configuration settings in your project.--collect <DATA_COLLECTOR_NAME>β Enables data collector for the test run. For more information, see Monitor and analyze test run (https://aka.ms/vstest-collect). For example you can collect code coverage by using the--collect "Code Coverage"option. For more information, see Use code coverage, Customize code coverage analysis, and GitHub issuedotnet/docs#34479(https://github.com/dotnet/docs/issues/34479).- Also, bestie, for code coverage you can lowkey just use Coverlet (https://github.com/coverlet-coverage/coverlet/blob/master/README.md) by passing the
--collect "XPlat Code Coverage"option. π -d,--diag <LOG_FILE>β turns on diagnostic mode for the test platform, and it writes diagnostic messages to the file you named plus the files hanging out right next to it. Which files actually get created is up to the process doing the logging β think*.host_<date>.txtfor the test host log, and*.datacollector_<date>.txtfor the data collector log. π--disable-build-serversβ forces the command to ignore any persistent build servers. This is the consistent way to shut off all use of build caching, which forces a build from scratch. And why would anyone want that? Because a build that doesn't rely on caches is genuinely useful when the caches might be corrupted or incorrect for some reason. Available since .NET 7 SDK. π-e,--environment <NAME="VALUE">β sets the value of an environment variable. Doesn't exist yet? It creates the variable. Already exists? It overrides it. Heads up though: using this option will force the tests to be run in an isolated process. And yes, you can stack it β specify this option multiple times to provide multiple variables. π«Ά-f,--framework <FRAMEWORK>β the target framework moniker (TFM) of the target framework you want to run tests for. Note that the target framework must also be specified in the project file. π--filter <EXPRESSION>β filters the tests in the current project using the expression you give it. Only tests that match the filter expression actually run. More deets live in the Filter option details section, and for more info and examples on how to use selective unit test filtering, go read Running selective unit tests. π-?,-h,--helpβ prints out a description of how to use the command. Classic. β¨--interactiveβ lets the command stop and wait for user input or action. Like, for example, to complete authentication. Available since .NET Core 3.0 SDK. π§-l,--logger <LOGGER>β specifies a logger for test results, and optionally the switches for that logger. Specify this parameter multiple times to enable multiple loggers. For more info, see Reporting test results (https://github.com/microsoft/vstest/blob/main/docs/report.md#available-test-loggers), Switches for loggers, and the examples later in this article. π
So how do you actually pass command-line switches to the logger? Follow this, fr fr:
- Use the full name of the switch, not the abbreviated form (for example,
verbosityinstead ofv). - Omit any leading dashes.
- Replace the space separating each switch with a semicolon
;. - If the switch has a value, replace the colon separator between that switch and its value with the equals sign
=.
For example, -v:detailed --consoleLoggerParameters:ErrorsOnly would become verbosity=detailed;consoleLoggerParameters=ErrorsOnly. π
--no-buildβ doesn't build the test project before running it. It also implicitly sets the--no-restoreflag. π«π¨--nologoβ run tests without displaying the Microsoft TestPlatform banner. Available since .NET Core 3.0 SDK. β¨--no-restoreβ doesn't execute an implicit restore when running the command. π-o,--output <OUTPUT_DIRECTORY>β the directory in which to find the binaries to run. If you don't specify it, the default path is./bin/<configuration>/<framework>/. For projects with multiple target frameworks (via theTargetFrameworksproperty), you also need to define--frameworkwhen you specify this option.dotnet testalways runs tests from the output directory. You can use<xref:System.AppDomain.BaseDirectory%2A?displayProperty=nameWithType>to consume test assets in the output directory. π- .NET 7.0.200 SDK and later
If you specify the --output option when running this command on a solution, the CLI will emit a warning (an error in 7.0.200) due to the unclear semantics of the output path. The --output option is disallowed because all outputs of all built projects would be copied into the specified directory, which isn't compatible with multi-targeted projects, as well as projects that have different versions of direct and transitive dependencies. For more info, see Solution-level --output option no longer valid for build-related commands. π
--os <OS>β specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the value you provide gets combined with the default RID. For example, on awin-x64machine, specifying--os linuxsets the RID tolinux-x64. If you use this option, don't use the-r|--runtimeoption. Available since .NET 6. π§--results-directory <RESULTS_DIR>β the directory where the test results are going to be placed. If the specified directory doesn't exist, it's created. The default isTestResultsin the directory that contains the project file. Short form-ravailable in .NET SDK versions earlier than 7. π-r,--runtime <RUNTIME_IDENTIFIER>β the target runtime to test for. Short form-ravailable starting in .NET SDK 7. π¦-s,--settings <SETTINGS_FILE>β the.runsettingsfile to use for running the tests. Heads up: theTargetPlatformelement (x86|x64) has no effect fordotnet test. To run tests that target x86, install the x86 version of .NET Core. The bitness of thedotnet.exethat is on the path is what will be used for running tests. For more info, see these resources: πΈ- Configure unit tests by using a
.runsettingsfile. - Configure a test run (https://github.com/microsoft/vstest/blob/main/docs/configure.md)
- Configure unit tests by using a
-t,--list-testsβ list the discovered tests instead of running the tests. π--tl:[auto|on|off]β specifies whether Terminal Logger should be used for the build output. The default isauto, which first verifies the environment before enabling terminal logging. That environment check verifies the terminal is capable of using modern output features and isn't using a redirected standard output before enabling the new logger.onskips the environment check and enables terminal logging.offskips the environment check and uses the default console logger. π
Terminal Logger shows you the restore phase followed by the build phase. During each phase, the currently building projects appear at the bottom of the terminal. Each project that's building outputs both the MSBuild target currently being built and the amount of time spent on that target. You can search this information to learn more about the build. When a project is finished building, a single "build completed" section is written that captures: β¨
- The name of the built project.
- The target framework (if multi-targeted).
- The status of that build.
- The primary output of that build (which is hyperlinked).
- Any diagnostics generated for that project.
This option is available starting in .NET 8. π
-v,--verbosity <LEVEL>β sets the verbosity level of the command. Allowed values areq[uiet],m[inimal],n[ormal],d[etailed], anddiag[nostic]. The default isminimal. For more info, see<xref:Microsoft.Build.Framework.LoggerVerbosity>. π₯argsβ specifies extra arguments to pass to the adapter. Use a space to separate multiple arguments. π«Ά
The list of possible arguments depends upon the specified behavior:
- When you specify a project, solution, or a directory, or if you omit this argument, the call is forwarded to
msbuild. In that case, the available arguments can be found in thedotnet msbuilddocumentation. - When you specify a
.dllor an.exe, the call is forwarded tovstest. In that case, the available arguments can be found in thedotnet vstestdocumentation.
- RunSettings arguments π
Inline RunSettings are passed as the last arguments on the command line after "β" (note the space after β). Inline RunSettings are specified as [name]=[value] pairs. A space is used to separate multiple [name]=[value] pairs.
Example: dotnet test -- MSTest.DeploymentEnabled=false MSTest.MapInconclusiveToFailed=True
For more info, see Passing RunSettings arguments through command line (https://github.com/Microsoft/vstest-docs/blob/main/docs/RunSettingsArguments.md). π
β¨ EXAMPLES β¨
Bestie, this is the part where it all clicks. Buckle up. π
- Run the tests in the project in the current directory:
dotnet test
- Run the tests in the
test1project:
dotnet test ~/projects/test1/test1.csproj
- Run the tests using
test1.dllassembly:
dotnet test ~/projects/test1/bin/debug/test1.dll
- Run the tests in the project in the current directory, and generate a test results file in the
trxformat:
dotnet test --logger trx
- Run the tests in the project in the current directory, and generate a code coverage file using Microsoft Code Coverage (
https://github.com/microsoft/codecoverage/blob/main/README.md):
dotnet test --collect "Code Coverage"
- Run the tests in the project in the current directory, and generate a code coverage file using Coverlet (
https://github.com/coverlet-coverage/coverlet/blob/master/README.md) (after installing Coverlet collectors integration (https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md)):
dotnet test --collect:"XPlat Code Coverage"
- Run the tests in the project in the current directory, and log with detailed verbosity to the console:
dotnet test --logger "console;verbosity=detailed"
- Run the tests in the project in the current directory, and log with the
trxlogger totestResults.trxin theTestResultsfolder:
dotnet test --logger "trx;logfilename=testResults.trx"
Since the log file name is specified, the same name is used for each target framework in the case of a multi-targeted project. The output for each target framework overwrites the output for preceding target frameworks. The file is created in the TestResults folder in the test project folder, because relative paths are relative to that folder. The following example shows how to produce a separate file for each target framework.
- Run the tests in the project in the current directory, and log with the
trxlogger to files in theTestResultsfolder, with file names that are unique for each target framework:
dotnet test --logger:"trx;LogFilePrefix=testResults"
- Run the tests in the project in the current directory, and log with the
htmllogger totestResults.htmlin theTestResultsfolder:
dotnet test --logger "html;logfilename=testResults.html"
- Run the tests in the project in the current directory, and report tests that were in progress when the test host crashed:
dotnet test --blame
- Run the tests in the
test1project, providing the-bl(binary log) argument tomsbuild:
dotnet test ~/projects/test1/test1.csproj -bl
- Run the tests in the
test1project, setting the MSBuildDefineConstantsproperty toDEV:
dotnet test ~/projects/test1/test1.csproj -p:DefineConstants="DEV"
- Run the tests in the
test1project, setting the MSBuildTestTfmsInParallelproperty tofalse:
dotnet test ~/projects/test1/test1.csproj -p:TestTfmsInParallel=false
πΈ Filter option details πΈ
--filter <EXPRESSION>
<Expression> has the format <property><operator><value>[|&<Expression>].
<property> is an attribute of the Test Case. The following are the properties supported by popular unit test frameworks:
- MSTest
- xUnit
- NUnit
The <operator> describes the relationship between the property and the value:
=β Exact match!=β Not exact match~β Contains!~β Not contains
<value> is a string. All the lookups are case insensitive.
An expression without an <operator> is automatically considered as a contains on FullyQualifiedName property (for example, dotnet test --filter xyz is same as dotnet test --filter FullyQualifiedName~xyz).
Expressions can be joined with conditional operators:
|β OR&β AND
You can enclose expressions in parenthesis when using conditional operators (for example, (Name~TestMethod1) | (Name~TestMethod2)).
For more information and examples on how to use selective unit test filtering, see Running selective unit tests.
π SEE ALSO π
- Frameworks and Targets
- .NET Runtime Identifier (RID) catalog
- Passing runsettings arguments through commandline (
https://github.com/microsoft/vstest/blob/main/docs/RunSettingsArguments.md)
π dotnet test with MTP π
This article applies to: βοΈ .NET 10 SDK and later versions
π¦ SYNOPSIS π¦
dotnet test
[--project <PROJECT_PATH>]
[--solution <SOLUTION_PATH>]
[--test-modules <EXPRESSION>]
[--root-directory <ROOT_PATH>]
[--max-parallel-test-modules <NUMBER>]
[-a|--arch <ARCHITECTURE>]
[-c|--configuration <CONFIGURATION>]
[-f|--framework <FRAMEWORK>]
[--os <OS>]
[-r|--runtime <RUNTIME_IDENTIFIER>]
[-v|--verbosity <LEVEL>]
[--no-build]
[--no-restore]
[--no-ansi]
[--no-progress]
[--output <VERBOSITY_LEVEL>]
[--no-launch-profile]
[--no-launch-profile-arguments]
[<args>...]
dotnet test -h|--help
π DESCRIPTION π
With Microsoft Testing Platform, dotnet test operates faster than with VSTest. The test-related arguments are no longer fixed, as they are tied to the registered extensions in the test project(s). Moreover, MTP supports a globbing filter when running tests. For more information, see Microsoft.Testing.Platform.
[!WARNING] When Microsoft.Testing.Platform is opted in viaglobal.json,dotnet testexpects all test projects to use Microsoft.Testing.Platform. It is an error if any of the test projects use VSTest. π
π§ Implicit restore π§
You don't have to run dotnet restore because it's run implicitly by all commands that require a restore to occur, such as dotnet new, dotnet build, dotnet run, dotnet test, dotnet publish, and dotnet pack. To disable implicit restore, use the --no-restore option.
The dotnet restore command is still useful in certain scenarios where explicitly restoring makes sense, such as continuous integration builds in Azure DevOps Services or in build systems that need to explicitly control when the restore occurs.
For information about how to manage NuGet feeds, see the dotnet restore documentation.
β¨ OPTIONS β¨
okay so real talk: you can only use ONE of these at a time: --project, --solution, or --test-modules. They cannot be combined, periodt. Also, when you're using --test-modules, you can't specify --arch, --configuration, --framework, --os, or --runtime. Those options just aren't relevant for an already-built module. π
--project <PROJECT_PATH>β tells dotnet where your project file lives, either just the folder name or the whole full path. If you don't say anything, it defaults to the current directory. π--solution <SOLUTION_PATH>β same vibe but for a solution file. folder name or full path. defaults to the current directory if you ghost it. π--test-modules <EXPRESSION>β filters test modules using file globbing in .NET. only tests belonging to those test modules will run. for more info and examples on how to use file globbing in .NET, see File globbing. β¨--root-directory <ROOT_PATH>β sets the root directory for the--test-modulesoption. it can only be used with the--test-modulesoption. π¦--max-parallel-test-modules <NUMBER>β max number of test modules that can run in parallel. parallel bestie energy activated. π--arch <ARCHITECTURE>β specifies the target architecture. this is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. for example, on awin-x64machine, specifying--arch x86sets the RID towin-x86. if you use this option, don't use the-r|--runtimeoption. available since .NET 6 Preview 7. π₯-c|--configuration <CONFIGURATION>β defines the build configuration. the default for most projects isDebug, but you can override the build configuration settings in your project. π-f|--framework <FRAMEWORK>β the target framework moniker (TFM) of the target framework to run tests for. the target framework must also be specified in the project file. πΈ--os <OS>β specifies the target operating system (OS). this is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. for example, on awin-x64machine, specifying--os linuxsets the RID tolinux-x64. if you use this option, don't use the-r|--runtimeoption. available since .NET 6. π-r|--runtime <RUNTIME_IDENTIFIER>β the target runtime to test for. short form-ravailable starting in .NET SDK 7.
β οΈ Running tests for a solution with a globalRuntimeIdentifierproperty (explicitly or via--arch,--runtime, or--os) is not supported. SetRuntimeIdentifieron an individual project level instead. π
-v|--verbosity <LEVEL>β sets the MSBuild verbosity level. allowed values areq[uiet],m[iniβmal],n[ormal],d[etailed], anddiag[nostic]. for more information, see<xref:Microsoft.Build.Framework.LoggerVerbosity>. π₯--no-buildβ specifies that the test project isn't built before being run. it also implicitly sets the--no-restoreflag. π--no-restoreβ specifies that an implicit restore isn't executed when running the command. π--no-ansiβ disables outputting ANSI escape characters to screen. no rainbow text, sad. π--no-progressβ disables reporting progress to screen. π§--output <VERBOSITY_LEVEL>β specifies the output verbosity when reporting tests. valid values areNormalandDetailed. the default isNormal. π--no-launch-profileβ do not attempt to uselaunchSettings.jsonto configure the application. by default,launchSettings.jsonis used, which can apply environment variables and command-line arguments to the test executable. β--no-launch-profile-argumentsβ do not use arguments specified bycommandLineArgsin launch profile to run the application. π--property:<NAME>=<VALUE>β sets one or more MSBuild properties. specify multiple properties by repeating the option:
--property:<NAME1>=<VALUE1> --property:<NAME2>=<VALUE2>
the short form -p can be used for --property. the same applies for /property:property=value and its short form is /p. more info about the available arguments can be found in the dotnet msbuild documentation. π
-?|-h|--helpβ prints out a description of how to use the command. some options are static while others, namely platform and extension options, are dynamic. these dynamic options might differ from one test application to another, as they are based on the registered extensions in the test project. π«Άargsβ specifies extra arguments to pass to the test application(s). use a space to separate multiple arguments. for more information and examples on what to pass, see Microsoft.Testing.Platform overview and Microsoft.Testing.Platform extensions. π₯
[!TIP] To specify extra arguments for specific projects, use the TestingPlatformCommandLineArguments MSBuild property.
To enable trace logging to a file, use the environment variable DOTNET_CLI_TEST_TRACEFILE to provide the path to the trace file. π
πΈ EXAMPLES πΈ
- run the tests in the project or solution in the current directory:
dotnet test
- run the tests in the TestProject project:
dotnet test --project ./TestProject/TestProject.csproj
- run the tests in the TestProjects solution:
dotnet test --solution ./TestProjects/TestProjects.sln
- run the tests using TestProject.dll assembly:
dotnet test --test-modules "**/bin/**/Debug/net10.0/TestProject.dll"
- run the tests using TestProject.dll assembly with the root directory:
dotnet test --test-modules "**/bin/**/Debug/net10.0/TestProject.dll" --root-directory "c:\code"
- run the tests in the current directory with code coverage:
dotnet test --coverage
- run the tests in the TestProject project, providing the
-bl(binary log) argument to msbuild:
dotnet test --project ./TestProject/TestProject.csproj -bl
- run the tests in the TestProject project, setting the MSBuild
DefineConstantsproperty toDEV:
dotnet test --project ./TestProject/TestProject.csproj -p:DefineConstants="DEV"
π¦ SEE ALSO π¦
- Frameworks and Targets
- .NET Runtime Identifier (RID) catalog
- Microsoft.Testing.Platform
- Microsoft.Testing.Platform extensions
that's the tea, bestie! this page is from dotnet-test(1) and it was last updated on 2025-10-30. now go run some tests and slay π
β¨
π¦ where this page comes from
- alpine 3.24: dotnet-doc 10.0.303-r2 Β· MIT
- centos-stream 10: dotnet-host 11.0.0~rc.2.26504.105-0.10.el10 Β· 0BSD AND Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND APSL-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND BSL-1.0 AND bzip2-1.0.6 AND CC0-1.0 AND CC-BY-3.0 AND CC-BY-4.0 AND CC-PDDC AND CNRI-Python AND EPL-1.0 AND GPL-2.0-only AND (GPL-2.0-only WITH GCC-exception-2.0) AND GPL-2.0-or-later AND GPL-3.0-only AND ICU AND ISC AND LGPL-2.1-only AND LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND LicenseRef-ISO-8879 AND MIT AND MIT-Wu AND MS-PL AND MS-RL AND NCSA AND OFL-1.1 AND OpenSSL AND Unicode-DFS-2015 AND Unicode-DFS-2016 AND W3C-19980720 AND X11 AND Zlib
- centos-stream 9: dotnet-host 11.0.0~rc.2.26504.105-0.11.el9 Β· 0BSD AND Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND APSL-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND BSL-1.0 AND bzip2-1.0.6 AND CC0-1.0 AND CC-BY-3.0 AND CC-BY-4.0 AND CC-PDDC AND CNRI-Python AND EPL-1.0 AND GPL-2.0-only AND (GPL-2.0-only WITH GCC-exception-2.0) AND GPL-2.0-or-later AND GPL-3.0-only AND ICU AND ISC AND LGPL-2.1-only AND LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND LicenseRef-ISO-8879 AND MIT AND MIT-Wu AND MS-PL AND MS-RL AND NCSA AND OFL-1.1 AND OpenSSL AND Unicode-DFS-2015 AND Unicode-DFS-2016 AND W3C-19980720 AND X11 AND Zlib
- fedora 43: dotnet-host 10.0.12-1.fc43
- fedora 43: dotnet-host 11.0.0~rc.1.26425.128-0.10.fc43 Β· 0BSD AND Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND APSL-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND BSL-1.0 AND bzip2-1.0.6 AND CC0-1.0 AND CC-BY-3.0 AND CC-BY-4.0 AND CC-PDDC AND CNRI-Python AND EPL-1.0 AND GPL-2.0-only AND (GPL-2.0-only WITH GCC-exception-2.0) AND GPL-2.0-or-later AND GPL-3.0-only AND ICU AND ISC AND LGPL-2.1-only AND LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND LicenseRef-ISO-8879 AND MIT AND MIT-Wu AND MS-PL AND MS-RL AND NCSA AND OFL-1.1 AND OpenSSL AND Unicode-DFS-2015 AND Unicode-DFS-2016 AND W3C-19980720 AND X11 AND Zlib
- fedora 44: dotnet-host 10.0.12-1.fc44
- fedora 44: dotnet-host 10.0.4-1.fc44 Β· 0BSD AND Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND APSL-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND BSL-1.0 AND bzip2-1.0.6 AND CC0-1.0 AND CC-BY-3.0 AND CC-BY-4.0 AND CC-PDDC AND CNRI-Python AND EPL-1.0 AND GPL-2.0-only AND (GPL-2.0-only WITH GCC-exception-2.0) AND GPL-2.0-or-later AND GPL-3.0-only AND ICU AND ISC AND LGPL-2.1-only AND LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND LicenseRef-ISO-8879 AND MIT AND MIT-Wu AND MS-PL AND MS-RL AND NCSA AND OFL-1.1 AND OpenSSL AND Unicode-DFS-2015 AND Unicode-DFS-2016 AND W3C-19980720 AND X11 AND Zlib
- fedora 44: dotnet-host 11.0.0~rc.1.26425.128-0.12.fc44 Β· 0BSD AND Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND APSL-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND BSL-1.0 AND bzip2-1.0.6 AND CC0-1.0 AND CC-BY-3.0 AND CC-BY-4.0 AND CC-PDDC AND CNRI-Python AND EPL-1.0 AND GPL-2.0-only AND (GPL-2.0-only WITH GCC-exception-2.0) AND GPL-2.0-or-later AND GPL-3.0-only AND ICU AND ISC AND LGPL-2.1-only AND LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND LicenseRef-ISO-8879 AND MIT AND MIT-Wu AND MS-PL AND MS-RL AND NCSA AND OFL-1.1 AND OpenSSL AND Unicode-DFS-2015 AND Unicode-DFS-2016 AND W3C-19980720 AND X11 AND Zlib
- nixpkgs unstable: dotnet-vmr 11.0.0-rc.3
- ubuntu noble: dotnet-host-10.0 10.0.12-0ubuntu1~24.04.1
- ubuntu questing: dotnet-host-10.0 10.0.9-0ubuntu1~25.10.1
- ubuntu resolute: dotnet-host-10.0 10.0.12-0ubuntu1~26.04.1
- ubuntu resolute: dotnet-host-10.0 10.0.5-0ubuntu1 Β· MIT
- ubuntu stonking: dotnet-host-10.0 10.0.12-0ubuntu2 Β· MIT
- ubuntu stonking: dotnet-host-11.0 11.0.0~rc1-0ubuntu1 Β· MIT
- ubuntu stonking: dotnet-host-11.0 11.0.0~rc3-0ubuntu1~26.10.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms