You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `dotnet test` command is used to execute unit tests in a given project. The `dotnet test` command launches the test runner console application specified for a project. The test runner executes the tests defined for a unit test framework (for example, MSTest, NUnit, or xUnit) and reports the success or failure of each test. If all tests are successful, the test runner returns 0 as an exit code; otherwise if any test fails, it returns 1. For multi-targeted projects, tests are run for each targeted framework. The test runner and the unit test library are packaged as NuGet packages and are restored as ordinary dependencies for the project.
34
+
The `dotnet test` command is used to execute unit tests in a given solution. The `dotnet test` command builds the solution and runs a test host application for each test project in the solution. The test host executes 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 all tests are successful, the test runner returns 0 as an exit code; otherwise if any test fails, it returns 1.
35
+
36
+
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.
35
37
36
38
Test projects specify the test runner using an ordinary `<PackageReference>` element, as seen in the following sample project file:
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.
- Path to a directory that contains a project or a solution.
55
+
- Path to a test project *.dll* file.
47
56
48
-
Path to the test project or solution. If not specified, it defaults to current directory.
57
+
If not specified, it searches for a project or a solution in the current directory.
49
58
50
59
## Options
51
60
52
61
-**`-a|--test-adapter-path <PATH_TO_ADAPTER>`**
53
62
54
-
Use the custom test adapters from the specified path in the test run.
63
+
Path to a directory to be searched for additional test adapters. Only *.dll* files with suffix `.TestAdapter.dll` are inspected. If not specified, the directory of the test *.dll* is searched.
55
64
56
65
-**`--blame`**
57
66
58
-
Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash. It creates an output file in the current directory as *Sequence.xml* that captures the order of tests execution before the crash.
67
+
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 an sequence file in `TestResults/<Guid>/<Guid>_Sequence.xml` that captures the order of tests that were run before the crash.
59
68
60
69
-**`-c|--configuration <CONFIGURATION>`**
61
70
@@ -67,11 +76,11 @@ Test projects specify the test runner using an ordinary `<PackageReference>` ele
67
76
68
77
-**`-d|--diag <PATH_TO_DIAGNOSTICS_FILE>`**
69
78
70
-
Enables diagnostic mode for the test platform and writes diagnostic messages to the specified file.
79
+
Enables diagnostic mode for the test platform and writes diagnostic messages to the specified file and to files next to it. The process that is logging the messages determines which files are created, such as `*.host_<date>.txt` for test host log, and `*.datacollector_<date>.txt` for data collector log.
71
80
72
81
-**`-f|--framework <FRAMEWORK>`**
73
82
74
-
Looks for test binaries for a specific [framework](../../standard/frameworks.md).
83
+
Forces the use of `dotnet` or .NET Framework test host for the test binaries. This option only determines which type of host to use. The actual framework version to be used is determined by the *runtimeconfig.json* of the test project. When not specified, the [TargetFramework assembly attribute](/dotnet/api/system.runtime.versioning.targetframeworkattribute) is used to determine the type of host. When that attribute is stripped from the *.dll*, the .NET Framework host is used.
75
84
76
85
-**`--filter <EXPRESSION>`**
77
86
@@ -115,7 +124,7 @@ Test projects specify the test runner using an ordinary `<PackageReference>` ele
115
124
116
125
-**`-s|--settings <SETTINGS_FILE>`**
117
126
118
-
The `.runsettings` file to use for running the tests. Note that the `TargetPlatform` element (x86|x64) has no effect for `dotnet test`. To run tests that target x86, install the x86 version of .NET Core. The bitness of the *dotnet.exe* that is on the path is what will be used for running tests. for more information, see the following resources:
127
+
The `.runsettings` file to use for running the tests. Note that the `TargetPlatform` element (x86|x64) has no effect for `dotnet test`. To run tests that target x86, install the x86 version of .NET Core. The bitness of the *dotnet.exe* that is on the path is what will be used for running tests. For more information, see the following resources:
119
128
120
129
-[Configure unit tests by using a `.runsettings` file.](/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file)
121
130
-[Configure a test run](https://github.com/Microsoft/vstest-docs/blob/master/docs/configure.md)
@@ -130,7 +139,7 @@ Test projects specify the test runner using an ordinary `<PackageReference>` ele
130
139
131
140
-**`RunSettings`** arguments
132
141
133
-
Arguments are passed as `RunSettings` configurations for the test. Arguments are specified as `[name]=[value]` pairs after "-- " (note the space after --). A space is used to separate multiple `[name]=[value]` pairs.
142
+
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.
134
143
135
144
Example: `dotnet test -- MSTest.DeploymentEnabled=false MSTest.MapInconclusiveToFailed=True`
136
145
@@ -161,6 +170,12 @@ Test projects specify the test runner using an ordinary `<PackageReference>` ele
161
170
```dotnetcli
162
171
dotnet test --logger "console;verbosity=detailed"
163
172
```
173
+
174
+
- Run the tests in the project in the current directory, and report tests that were in progress when the test host crashed:
0 commit comments