1dotnet test command(1)             .NET Core            dotnet test command(1)
2
3
4

dotnet test

NAME

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

SYNOPSIS

10   .NET Core 2.1
11              dotnet test [<PROJECT>] [-a|--test-adapter-path] [--blame] [-c|--configuration] [--collect] [-d|--diag] [-f|--framework] [--filter]
12                  [-l|--logger] [--no-build] [--no-restore] [-o|--output] [-r|--results-directory] [-s|--settings] [-t|--list-tests]
13                  [-v|--verbosity] [-- <RunSettings arguments>]
14
15              dotnet test [-h|--help]
16
17   .NET Core 2.0
18              dotnet test [<PROJECT>] [-a|--test-adapter-path] [-c|--configuration] [--collect] [-d|--diag] [-f|--framework] [--filter]
19                  [-l|--logger] [--no-build] [--no-restore] [-o|--output] [-r|--results-directory] [-s|--settings] [-t|--list-tests] [-v|--verbosity]
20
21              dotnet test [-h|--help]
22
23   .NET Core 1.x
24              dotnet test [<PROJECT>] [-a|--test-adapter-path] [-c|--configuration] [-d|--diag] [-f|--framework] [--filter] [-l|--logger] [--no-build] [-o|--output] [-s|--settings] [-t|--list-tests]  [-v|--verbosity]
25
26              dotnet test [-h|--help]
27
28          *   *   *   *   *
29

DESCRIPTION

31       The  dotnet  test  command  is  used  to  execute unit tests in a given
32       project.  The dotnet test command launches the test runner console  ap‐
33       plication  specified for a project.  The test runner executes the tests
34       defined for a unit test framework (for example, MSTest, NUnit,  or  xU‐
35       nit) and reports the success or failure of each test.  If all tests are
36       successful, the test runner returns 0 as an exit code; otherwise if any
37       test  fails,  it  returns 1.  The test runner and the unit test library
38       are packaged as NuGet packages and are restored as  ordinary  dependen‐
39       cies for the project.
40
41       Test  projects specify the test runner using an ordinary <PackageRefer‐
42       ence> element, as seen in the following sample project file:
43
44       [!code-xmlXUnit Basic Template]
45
46   Arguments
47       PROJECT
48
49       Path to the test project.  If not specified, it defaults to current di‐
50       rectory.
51

OPTIONS

53   .NET Core 2.1
54       -a|--test-adapter-path <PATH_TO_ADAPTER>
55
56       Use the custom test adapters from the specified path in the test run.
57
58       --blame
59
60       Runs  the tests in blame mode.  This option is helpful in isolating the
61       problematic tests causing test host to crash.   It  creates  an  output
62       file  in  the current directory as Sequence.xml that captures the order
63       of tests execution before the crash.
64
65       -c|--configuration {Debug|Release}
66
67       Defines the build configuration.  The default value is Debug, but  your
68       project’s configuration could override this default SDK setting.
69
70       --collect <DATA_COLLECTOR_FRIENDLY_NAME>
71
72       Enables  data  collector  for  the test run.  For more information, see
73       Monitor and analyze test run.
74
75       -d|--diag <PATH_TO_DIAGNOSTICS_FILE>
76
77       Enables diagnostic mode for the test platform and write diagnostic mes‐
78       sages to the specified file.
79
80       -f|--framework <FRAMEWORK>
81
82       Looks for test binaries for a specific framework.
83
84       --filter <EXPRESSION>
85
86       Filters  out  tests  in the current project using the given expression.
87       For more information, see the Filter option details section.  For  more
88       information  and  examples on how to use selective unit test filtering,
89       see Running selective unit tests.
90
91       -h|--help
92
93       Prints out a short help for the command.
94
95       -l|--logger <LoggerUri/FriendlyName>
96
97       Specifies a logger for test results.
98
99       --no-build
100
101       Doesn’t build the test project before running  it.   It  also  implicit
102       sets the --no-restore flag.
103
104       --no-restore
105
106       Doesn’t execute an implicit restore when running the command.
107
108       -o|--output <OUTPUT_DIRECTORY>
109
110       Directory in which to find the binaries to run.
111
112       -r|--results-directory <PATH>
113
114       The  directory  where  the test results are going to be placed.  If the
115       specified directory doesn’t exist, it’s created.
116
117       -s|--settings <SETTINGS_FILE>
118
119       The .runsettings file to use for running  the  tests.   Configure  unit
120       tests by using a .runsettings file.
121
122       -t|--list-tests
123
124       List all of the discovered tests in the current project.
125
126       -v|--verbosity <LEVEL>
127
128       Sets  the  verbosity level of the command.  Allowed values are q[uiet],
129       m[inimal], n[ormal], d[etailed], and diag[nostic].
130
131       RunSettings arguments
132
133       Arguments passed as RunSettings configurations for the test.  Arguments
134       are  specified  as [name]=[value] pairs after “–” (note the space after
135       –).  A space is used to separate multiple [name]=[value] pairs.
136
137       Example: dotnet test -- MSTest.DeploymentEnabled=false MSTest.MapIncon‐
138       clusiveToFailed=True
139
140       For more information about RunSettings, see vstest.console.exe: Passing
141       RunSettings args.
142
143   .NET Core 2.0
144       -a|--test-adapter-path <PATH_TO_ADAPTER>
145
146       Use the custom test adapters from the specified path in the test run.
147
148       -c|--configuration {Debug|Release}
149
150       Defines the build configuration.  The default value is Debug, but  your
151       project’s configuration could override this default SDK setting.
152
153       --collect <DATA_COLLECTOR_FRIENDLY_NAME>
154
155       Enables  data  collector  for  the test run.  For more information, see
156       Monitor and analyze test run.
157
158       -d|--diag <PATH_TO_DIAGNOSTICS_FILE>
159
160       Enables diagnostic mode for the test platform and write diagnostic mes‐
161       sages to the specified file.
162
163       -f|--framework <FRAMEWORK>
164
165       Looks for test binaries for a specific framework.
166
167       --filter <EXPRESSION>
168
169       Filters  out  tests  in the current project using the given expression.
170       For more information, see the Filter option details section.  For  more
171       information  and  examples on how to use selective unit test filtering,
172       see Running selective unit tests.
173
174       -h|--help
175
176       Prints out a short help for the command.
177
178       -l|--logger <LoggerUri/FriendlyName>
179
180       Specifies a logger for test results.
181
182       --no-build
183
184       Doesn’t build the test project before running  it.   It  also  implicit
185       sets the --no-restore flag.
186
187       --no-restore
188
189       Doesn’t execute an implicit restore when running the command.
190
191       -o|--output <OUTPUT_DIRECTORY>
192
193       Directory in which to find the binaries to run.
194
195       -r|--results-directory <PATH>
196
197       The  directory  where  the test results are going to be placed.  If the
198       specified directory doesn’t exist, it’s created.
199
200       -s|--settings <SETTINGS_FILE>
201
202       The .runsettings file to use for running  the  tests.   Configure  unit
203       tests by using a .runsettings file.
204
205       -t|--list-tests
206
207       List all of the discovered tests in the current project.
208
209       -v|--verbosity <LEVEL>
210
211       Sets  the  verbosity level of the command.  Allowed values are q[uiet],
212       m[inimal], n[ormal], d[etailed], and diag[nostic].
213
214   .NET Core 1.x
215       -a|--test-adapter-path <PATH_TO_ADAPTER>
216
217       Use the custom test adapters from the specified path in the test run.
218
219       -c|--configuration {Debug|Release}
220
221       Defines the build configuration.  The default value is Debug, but  your
222       project’s configuration could override this default SDK setting.
223
224       -d|--diag <PATH_TO_DIAGNOSTICS_FILE>
225
226       Enables diagnostic mode for the test platform and write diagnostic mes‐
227       sages to the specified file.
228
229       -f|--framework <FRAMEWORK>
230
231       Looks for test binaries for a specific framework.
232
233       --filter <EXPRESSION>
234
235       Filters out tests in the current project using  the  given  expression.
236       For  more information, see the Filter option details section.  For more
237       information and examples on how to use selective unit  test  filtering,
238       see Running selective unit tests.
239
240       -h|--help
241
242       Prints out a short help for the command.
243
244       -l|--logger <LoggerUri/FriendlyName>
245
246       Specifies a logger for test results.
247
248       --no-build
249
250       Doesn’t build the test project before running it.
251
252       -o|--output <OUTPUT_DIRECTORY>
253
254       Directory in which to find the binaries to run.
255
256       -s|--settings <SETTINGS_FILE>
257
258       The  .runsettings  file  to  use for running the tests.  Configure unit
259       tests by using a .runsettings file.
260
261       -t|--list-tests
262
263       List all of the discovered tests in the current project.
264
265       -v|--verbosity <LEVEL>
266
267       Sets the verbosity level of the command.  Allowed values  are  q[uiet],
268       m[inimal], n[ormal], d[etailed], and diag[nostic].
269
270          *   *   *   *   *
271

EXAMPLES

273       Run the tests in the project in the current directory:
274
275       dotnet test
276
277       Run the tests in the test1 project:
278
279       dotnet test ~/projects/test1/test1.csproj
280
281       Run  the  tests  in the project in the current directory and generate a
282       test results file in the trx format:
283
284       dotnet test --logger trx
285
286   Filter option details
287       --filter <EXPRESSION>
288
289       <Expression>  has  the  format   <property><operator><value>[|&<Expres‐
290       sion>].
291
292       <property>  is  an  attribute  of the Test Case.  The following are the
293       properties supported by popular unit test frameworks:
294
295       Test Framework   Supported properties
296       ──────────────────────────────────────
297       | MSTest | FullyQualifiedName Name ClassName Priority TestCategory |  |
298       xUnit | FullyQualifiedName DisplayName Traits
299
300                                             |
301
302       The  <operator> describes the relationship between the property and the
303       value:
304
305       Operator   Function
306       ───────────────────────────
307          =       Exact match
308          !=      Not exact match
309          ~       Contains
310
311       <value> is a string.  All the lookups are case insensitive.
312
313       An expression without an <operator> is automatically  considered  as  a
314       contains  on  FullyQualifiedName  property  (for  example,  dotnet test
315       --filter xyz is same as dotnet test --filter FullyQualifiedName~xyz).
316
317       Expressions can be joined with conditional operators:
318
319       Operator   Function
320       ────────────────────
321       |          OR
322       &          AND
323
324       You can enclose expressions in parenthesis when using conditional oper‐
325       ators (for example, (Name~TestMethod1) | (Name~TestMethod2)).
326
327       For  more  information  and  examples on how to use selective unit test
328       filtering, see Running selective unit tests.
329
330   See also
331       · Frameworks and Targets
332
333       · .NET Core Runtime IDentifier (RID) catalog
334
335
336
337                                                        dotnet test command(1)
Impressum