RunSettings and xunit.runner.visualstudio

Beginning with version 2.5.1 of xunit.runner.visualstudio, you can provide xUnit.net configuration settings via RunSettings. This includes a .RunSettings file to be used by Test Explorer, dotnet test, and vstest.console.exe, as well as by command line switches directly when calling dotnet test.

RunSettings are expressed as XML, and XML element names are case-sensitive. Please carefully verify that you are using the correct casing for the XML element names. This also applies to the command line switches for dotnet test, as they are transparently translated into XML elements behind the scenes.

Format of the .RunSettings file

The .RunSettings file is simply an XML file with a specific format. You will place your values inside an xUnit section in the configuration file. For example, to disable app domains and parallelization:

<RunSettings>
  <xUnit>
    <AppDomain>denied</AppDomain>
    <ParallelizeTestCollections>false</ParallelizeTestCollections>
  </xUnit>
</RunSettings>

For more information on using .RunSettings files, please see the Visual Studio documentation.

Format of the dotnet test command line switches

When passing RunSettings via the dotnet test command line, you will format them as xUnit.key=value pairs. For example, to disable app domains and parallelization:

  dotnet test path/to/myproject -- xUnit.AppDomain=denied xUnit.ParallelizeTestCollections=false

For more information on using command line switches for RunSettings with dotnet test, please see the dotnet test documentation.

Supported configuration items

Key Supported Values
AppDomain
xunit.runner.visualstudio 2.5.1+
Test Framework v1-v2

Set this value to determine whether App Domains are used. By default, they will be used when available (the ifAvailable value). If you set this to required, it will require that app domains are available; if you set this to denied, it will not use app domains. Note that App Domains are only supported with .NET Framework tests, and only with tests linked against xUnit.net framework v1 or v2.

Valid values: required, ifAvailable, denied
Default value: ifAvailable

Culture
xunit.runner.visualstudio 3.0.0-pre.41+
Test Framework v3+

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
xunit.runner.visualstudio 2.5.1+
Test Framework v2+

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
xunit.runner.visualstudio 3.0.0-pre.41+
Test Framework v3+

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
xunit.runner.visualstudio 2.5.1+
Test Framework v1+

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

Valid values: true, false
Default value: false

FailWarns
xunit.runner.visualstudio 3.0.0-pre.41+
Test Framework v3+

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
xunit.runner.visualstudio 2.5.1+
Test Framework v2+

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
xunit.runner.visualstudio 2.5.1+

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
xunit.runner.visualstudio 2.5.1+
Test Framework v2+

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
xunit.runner.visualstudio 2.5.1+
Test Framework v2+

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
xunit.runner.visualstudio 2.5.1+
Test Framework v2+

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

NoAutoReporters
xunit.runner.visualstudio 2.5.1+
Test Framework v1+

Set this to true to disable automatically enabled reporters (for example, reporters that automatically detect and enable support for AppVeyor, TeamCity, or Azure Pipelines). This is typically only used in debugging scenarios when trying to determine why tests aren't properly reporting into your CI environment.

Valid values: true, false
Default value: false

ParallelAlgorithm
xunit.runner.visualstudio 2.8.0+
Test Framework v2 2.8.0+

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

ParallelizeAssembly
xunit.runner.visualstudio 2.5.1+
Test Framework v2+

Set this to true if this assembly is willing to participate in parallelization with other assemblies. Test runners can use this information to automatically enable parallelization across assemblies if all the assemblies agree to it.

Valid values: true, false
Default value: false

ParallelizeTestCollections
xunit.runner.visualstudio 2.5.1+
Test Framework v2+

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
xunit.runner.visualstudio 2.5.1+
Test Framework v2+

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

ReporterSwitch
xunit.runner.visualstudio 2.5.1+
Test Framework v1+

Set this value to use a different reporter than the default. There are five reporters that ship with xunit.runner.visualstudio with behavior that deviates from the default:

  • quiet will only print failure information
  • verbose will print messages when tests start abd finish
  • json will print messages in a JSON format
  • teamcity will print TeamCity-formatted messages
  • silent turns off all messages (xunit.runner.visualstudio 2.5.4+)

Note: In order to see the reporter output, you will need to change the verbosity level of the console reporter. In Visual Studio, you can do this by opening the Options settings, navigating to Test > General, and the setting the drop down under "Logging Level" to "Diagnostic" (the logs in Visual Studio will appear in the Output window, under "Tests"). From the command line, you can pass --logger "console;verbosity=normal" on the dotnet test command line.

Valid values: quiet, verbose, json, teamcity
Default value: unset

Seed
xunit.runner.visualstudio 3.0.0-pre.41+
Test Framework v3+

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

ShadowCopy
xunit.runner.visualstudio 2.5.1+
Test Framework v1-v2

Set this to true to use shadow copying when running tests in separate App Domains; set to false to run tests without shadow copying. When running tests without App Domains, this value is ignored.

Valid values: true, false
Default value: true

ShowLiveOutput
xunit.runner.visualstudio 2.8.1+
Test Framework v2

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
xunit.runner.visualstudio 2.5.1+
Test Framework v2+

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.