Skip to content

Commit d9840e4

Browse files
authored
Improve MSTest testconfig doc (#44951)
1 parent ea1d886 commit d9840e4

File tree

1 file changed

+107
-7
lines changed

1 file changed

+107
-7
lines changed

docs/core/testing/unit-testing-mstest-configure.md

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,35 +117,97 @@ MSTest settings are grouped by functionality that are described in the sections
117117
| enableBaseClassTestMethodsFromOtherAssemblies | true | A value indicating whether to enable discovery of test methods from base classes in a different assembly from the inheriting test class. |
118118
| classCleanupLifecycle | EndOfAssembly | If you want the class cleanup to occur at the end of the class, set it to **EndOfClass**. |
119119

120-
#### AssemblyResolution settings
120+
#### `assemblyResolution` settings
121+
122+
All the settings in this section belong to the `assemblyResolution` element.
121123

122124
| Entry | Default | Description |
123125
|-------|---------|-------------|
124126
| paths | None | You can specify paths to extra assemblies when finding and running unit tests. For example, use these paths for dependency assemblies that aren't in the same directory as the test assembly. You can specify a path in the shape `{ "path": "...", "includeSubDirectories": "true/false" }`. |
125127

126-
#### Deployment settings
128+
Example:
129+
130+
```json
131+
{
132+
"mstest": {
133+
"assemblyResolution": {
134+
{ "path": "...", "includeSubDirectories": "true/false" }
135+
}
136+
}
137+
}
138+
```
139+
140+
#### `deployment` settings
141+
142+
All the settings in this section belong to the `deployment` element.
127143

128144
| Entry | Default | Description |
129145
|-------|---------|-------------|
130146
| deleteDeploymentDirectoryAfterTestRunIsComplete | true | To retain the deployment directory after a test run, set this value to **false**. |
131147
| deployTestSourceDependencies | true | Indicates whether the test source references are to be deployed. |
132148
| enabled | true | If you set the value to **false**, deployment items that you specify in your test method aren't copied to the deployment directory. |
133149

134-
#### Output settings
150+
Example:
151+
152+
```json
153+
{
154+
"mstest": {
155+
"deployment": {
156+
"deleteDeploymentDirectoryAfterTestRunIsComplete": true,
157+
"deployTestSourceDependencies": true,
158+
"enabled": true
159+
}
160+
}
161+
}
162+
```
163+
164+
#### `output` settings
165+
166+
All the settings in this section belong to the `output` element.
135167

136168
| Entry | Default | Description |
137169
|-------|---------|-------------|
138-
| captureTrace | false | Capture text messages coming from the `Console.Write*`, `Trace.Write*`, and `Debug.Write*` APIs that will be associated to the current running test. |
170+
| captureTrace | true | Capture text messages coming from the `Console.Write*`, `Trace.Write*`, and `Debug.Write*` APIs that will be associated to the current running test. |
171+
172+
Example:
173+
174+
```json
175+
{
176+
"mstest": {
177+
"output": {
178+
"captureTrace": false
179+
}
180+
}
181+
}
182+
```
183+
184+
#### `parallelism` settings
139185

140-
#### Parallelism settings
186+
All the settings in this section belong to the `parallelism` element.
141187

142188
| Entry | Default | Description |
143189
|-------|---------|-------------|
144190
| enabled | false | Enable test parallelization. |
145191
| scope | class | The scope of parallelization. You can set it to `method`. The default, `class`, corresponds to running all tests of a given class sequentially but multiple classes in parallel. |
146192
| workers | 0 | The number of threads/workers to be used for parallelization. The default value maps to the number of processors on the current machine. |
147193

148-
#### Execution settings
194+
Example:
195+
196+
```json
197+
{
198+
"mstest": {
199+
"parallelism": {
200+
"enabled": true,
201+
"scope": "method",
202+
"workers": 32
203+
}
204+
}
205+
}
206+
```
207+
208+
#### `execution` settings
209+
210+
All the settings in this section belong to the `execution` element.
149211

150212
| Entry | Default | Description |
151213
|-------|---------|-------------|
@@ -156,7 +218,26 @@ MSTest settings are grouped by functionality that are described in the sections
156218
| treatClassAndAssemblyCleanupWarningsAsErrors | false | To see your failures in class cleanups as errors, set this value to **true**. |
157219
| treatDiscoveryWarningsAsErrors | false | To report test discovery warnings as errors, set this value to **true**. |
158220

159-
#### Timeout settings
221+
Example:
222+
223+
```json
224+
{
225+
"mstest": {
226+
"execution": {
227+
"considerEmptyDataSourceAsInconclusive": false,
228+
"considerFixturesAsSpecialTests": false,
229+
"mapInconclusiveToFailed": true,
230+
"mapNotRunnableToFailed": true,
231+
"treatClassAndAssemblyCleanupWarningsAsErrors": false,
232+
"treatDiscoveryWarningsAsErrors": false
233+
}
234+
}
235+
}
236+
```
237+
238+
#### `timeout` settings
239+
240+
All the settings in this section belong to the `timeout` element.
160241

161242
| Entry | Default | Description |
162243
|-------|---------|-------------|
@@ -172,6 +253,25 @@ MSTest settings are grouped by functionality that are described in the sections
172253
> [!NOTE]
173254
> `[Timeout]` attribute specified on a method overrides the global timeout. For example, `[Timeout(1000)]` on a method marked with [AssemblyCleanup] will override the global `assemblyCleanup` timeout.
174255
256+
Example:
257+
258+
```json
259+
{
260+
"mstest": {
261+
"timeout": {
262+
"assemblyCleanup": 0,
263+
"assemblyInitialize": 0,
264+
"classCleanup": 0,
265+
"classInitialize": 0,
266+
"test": 0,
267+
"testCleanup": 0,
268+
"testInitialize": 0,
269+
"useCooperativeCancellation": false
270+
}
271+
}
272+
}
273+
```
274+
175275
### Example *testconfig.json* file
176276

177277
The following JSON shows the contents of a typical *.testconfig.json* file. Copy this code and edit it to suit your needs.

0 commit comments

Comments
 (0)