testconfig.json
with Microsoft Testing PlatformLast updated: 2025 June 7
Beginning with xUnit.net v3 version 3.0.0-pre.15
, when running tests in Microsoft Testing Platform mode, you can utilize testconfig.json
to provide test project configuration.
Using testconfig.json
is only supported when running tests in Microsoft Testing Platform mode. Running tests any other way (including using our first party runners or any non-Microsoft Testing Plateform third party runner) does not support testconfig.json
, and you should rely on xUnit.net’s native JSON configuration files instead. For more information about v3 and Microsoft Testing Platform, see our documentation page.
testconfig.json
fileassertEquivalentMaxDepth
culture
diagnosticMessages
explicit
failSkips
failWarns
internalDiagnosticMessages
longRunningTestSeconds
maxParallelThreads
methodDisplay
methodDisplayOptions
parallelAlgorithm
parallelizeTestCollections
preEnumerateTheories
printMaxEnumerableLength
printMaxObjectDepth
printMaxObjectMemberCount
printMaxStringLength
seed
showLiveOutput
stopOnFail
testconfig.json
fileThe testconfig.json
is a standard JSON file that lives in the root of your test project. xUnit.net configuration items are placed into a top-level object named xUnit
. For example, to set the runtime culture and disable parallelization:
{
"xUnit": {
"culture": "en-GB",
"parallelizeTestCollections": false
}
}
Key | Supported Values |
---|---|
assertEquivalentMaxDepth |
Set this value to limit the recursive depth
This can also be set by environment variable
Valid values: Any integer >= 1 |
culture |
Set this value to override the default culture used to run all unit tests in
the assembly. You can pass
Valid values: |
diagnosticMessages |
Set this value to
Valid values: |
explicit |
Change the way explicit tests are handled:
Valid values: |
failSkips |
Set this to
Valid values: |
failWarns |
Set this to
Valid values: |
internalDiagnosticMessages |
Set this value to
Valid values: |
longRunningTestSeconds |
Set this value to enable long-running (hung) test detection. When the runner is
idle waiting for tests to finished, it will report that fact once the timeout
has passed. Use a value of NOTE: Long running test messages are diagnostic messages. You must enable diagnostic messages in order to see the long running test warnings.
Valid values: Any integer >= 0 |
maxParallelThreads |
Set this to override the maximum number of threads to be used when parallelizing
tests within this assembly. Use a value of
As of v2 Test Framework 2.8.0+ and
Valid values: Any integer >= -1, a multiplier, |
methodDisplay |
Set this to override the default display name for test cases. If you set this
to
Valid values: |
methodDisplayOptions |
Set this to automatically perform transforms on default test names. This value
can either be
Valid values: |
parallelAlgorithm |
Set this to change the way tests are scheduled when they're running in parallel. For more
information, see Running Tests in Parallel.
Note that the algorithm only applies when you have enabled
test collection parallelism, and are using a limited number of
threads (i.e., not
Valid values: |
parallelizeTestCollections |
Set this to
Valid values: |
preEnumerateTheories
|
Set this to
This value does not have a default, because it's up to each individual test runner
to decide what the best default behavior is. The Visual Studio adapter, for example,
will default to
Valid values: |
</tr>
printMaxEnumerableLength |
Set this value to limit the number of items to print in a collection (followed by an ellipsis when the collection is longer). This is also used when printing into the middle of a collection with a mismatch index, which means the printing may also start with an ellipsis.
Set this to
This can also be set by environment variable
Valid values: Any integer >= 0 |
printMaxObjectDepth |
Set this value to limit the recursive depth when printing objects (followed by an ellipsis when the object depth is too deep).
Set this to
Important warning: disabling this when printing objects with circular references
could result in an infinite loop that will cause an
This can also be set by environment variable
Valid values: Any integer >= 0 |
printMaxObjectMemberCount |
Set this value to limit the the number of members (fields and properties) to include when printing objects (followed by an ellipsis when there are more members).
Set this to
This can also be set by environment variable
Valid values: Any integer >= 0 |
printMaxStringLength |
Set this value to limit the number of characters to print in a string (followed by an ellipsis when the collection is longer). This is also used when printing into the middle of a string with a mismatch index, which means the printing may also start with an ellipsis.
Set this to
This can also be set by environment variable
Valid values: Any integer >= 0 |
seed |
Set this to set the seed used for randomization (affects how the test cases are randomized). This is only valid for v3.0+ test assemblies; it will be ignored for v1 or v2 assemblies. If the seed value isn't set, then the system will determine a reasonable seed (and print that seed when running the test assembly, to assist you in reproducing order-dependent failures).
Valid values: between |
showLiveOutput |
Set this to
Valid values: |
stopOnFail |
Set this to
Valid values: |