Using testconfig.json with Microsoft Testing Platform

Last 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.

Table of contents

Format of the testconfig.json file

The 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
  }
}

Supported configuration items

</tr> </table>
Key Supported Values
assertEquivalentMaxDepth

Set this value to limit the recursive depth Assert.Equivalent will use when comparing objects for equivalence.

This can also be set by environment variable XUNIT_ASSERT_EQUIVALENT_MAX_DEPTH. A value in RunSettings will take precedence over the environment variable.

Valid values: Any integer >= 1
Default value: 50

culture

Set this value to override the default culture used to run all unit tests in the assembly. You can pass default to use the default behavior (use the default culture of the operating system); you can pass invariant to use the invariant culture; or you can pass any string which describes a valid culture on the target operating system (see BCP 47 for a description of how culture names are formatted; note that the list of supported cultures will vary by target operating system).

Valid values: default, invariant, any OS supported culture
Default value: default

diagnosticMessages

Set this value to true to include diagnostic information during test discovery and execution. Each runner has a unique method of presenting diagnostic messages.

Valid values: true, false
Default value: false

explicit

Change the way explicit tests are handled:

  • on Run both explicit and non-explicit tests
  • off Run only non-explicit tests
  • only Run only explicit tests

Valid values: on, off, only
Default value: off

failSkips

Set this to true to enable skipped tests to be treated as errors.

Valid values: true, false
Default value: false

failWarns

Set this to true to enable warned tests to be treated as errors. By default, warnings will be reported with a passing test result.

Valid values: true, false
Default value: false

internalDiagnosticMessages

Set this value to true to include internals diagnostic information during test discovery and execution. Each runner has a unique method of presenting diagnostic messages. Internal diagnostics often include information that is only useful when debugging the test framework itself.

Valid values: true, false
Default value: false

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 0 to disable the feature, or a positive integer value to enable the feature (time in seconds).

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
Default value: 0 (disabled)

maxParallelThreads

Set this to override the maximum number of threads to be used when parallelizing tests within this assembly. Use a value of 0 to indicate that you would like the default behavior; use a value of -1 to indicate that you do not wish to limit the number of threads used for parallelization.

As of v2 Test Framework 2.8.0+ and xunit.runner.visualstudio 2.8.0+, you can also use the multiplier syntax, which is a multiplier of the number of CPU threads. For example, 2.0x will give you double the CPU thread count. You may also use the string values unlimited and default in place of the integer values -1 and 0, respectively.

Valid values: Any integer >= -1, a multiplier, unlimited, or default
Default value: the number of CPU threads in your PC

methodDisplay

Set this to override the default display name for test cases. If you set this to method, the display name will be just the method (without the class name); if this set this value to classAndMethod, the default display name will be the fully qualified class name and method name.

Valid values: method, classAndMethod
Default value: classAndMethod

methodDisplayOptions

Set this to automatically perform transforms on default test names. This value can either be all, none, or a comma-separated combination of one or more of the following values:

  • replaceUnderscoreWithSpace Replaces all underscores with spaces
  • useOperatorMonikers Replaces operator names with matching symbols
    • eq becomes =
    • ne becomes !=
    • lt becomes <
    • le becomes <=
    • gt becomes >
    • ge becomes >=
  • useEscapeSequences Replaces escape sequences in the format Xnn or Unnnn with their ASCII or Unicode character equivalents. Examples:
    • X2C becomes ,
    • U1D0C becomes
  • replacePeriodWithComma Replaced periods with a comma and a space. This option is typically only useful if methodDisplay is classAndMethod.

Valid values: all, none, or comma separated flags
Default value: none

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 unlimited or -1).

Valid values: conservative, aggressive
Default value: conservative

parallelizeTestCollections

Set this to true if the assembly is willing to run tests inside this assembly in parallel against each other. Tests in the same test collection will be run sequentially against each other, but tests in different test collections will be run in parallel against each other. Set this to false to disable all parallelization within this test assembly.

Valid values: true, false
Default value: true

preEnumerateTheories

Set this to true to pre-enumerate theories so that there is an individual test case for each theory data row. Set this to false to return a single test case for each theory without pre-enumerating the data ahead of time (this is how xUnit.net v1 used to behave). This is most useful for developers running tests inside Visual Studio, who wish to have the Code Lens test runner icons on their theory methods, since Code Lens does not support multiple tests from a single method.

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 true, while the console and MSBuild runners will default to false.

Valid values: true, false

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 0 to always print the full collection.

This can also be set by environment variable XUNIT_PRINT_MAX_ENUMERABLE_LENGTH. A value in RunSettings will take precedence over the environment variable.

Valid values: Any integer >= 0
Default value: 5

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 0 to always print objects at all depths.

Important warning: disabling this when printing objects with circular references could result in an infinite loop that will cause an OutOfMemoryException and crash the test runner process.

This can also be set by environment variable XUNIT_PRINT_MAX_OBJECT_DEPTH. A value in RunSettings will take precedence over the environment variable.

Valid values: Any integer >= 0
Default value: 3

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 0 to always print all members.

This can also be set by environment variable XUNIT_PRINT_MAX_OBJECT_MEMBER_COUNT. A value in RunSettings will take precedence over the environment variable.

Valid values: Any integer >= 0
Default value: 5

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 0 to always print full strings.

This can also be set by environment variable XUNIT_PRINT_MAX_STRING_LENGTH. A value in RunSettings will take precedence over the environment variable.

Valid values: Any integer >= 0
Default value: 50

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 0 and 2147483647
Default value: unset

showLiveOutput

Set this to true to show messages from ITestOutputHelper live during the test run, in addition to showing them after the test has completed; set to false to only show test output messages after the test has completed. Note: when using dotnet test you may need to pass an extra command line option (--logger "console;verbosity=normal") to be able to see messages from xUnit.net, as they are hidden by default.

Valid values: true, false
Default value: false

stopOnFail

Set this to true to stop running further tests once a test has failed. (Because of the asynchronous nature of test execution, this will not necessarily happen immediately; any test that is already in flight may complete, which may result in multiple test failures reported.)

Valid values: true, false
Default value: false

Copyright © .NET Foundation. Contributions welcomed at https://github.com/xunit/xunit/tree/gh-pages.