Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Configure unit tests with a .runsettings file
description: Learn how to use the .runsettings file in Visual Studio to configure unit tests that are run from the command line, from the IDE, or in a build workflow.
ms.date: 12/17/2025
ms.date: 07/15/2026
ms.topic: how-to
ms.author: mikejo

Expand Down Expand Up @@ -150,6 +150,42 @@ To run tests from the command line, use *vstest.console.exe*, and specify the se

For more information, see [VSTest.Console.exe command-line options](vstest-console-options.md).

## Override run settings from the command line

You can also override some run settings directly from the command line. Specify run settings overrides after `--`. Include the space after `--`; all arguments after `--` are treated as run settings overrides, so these arguments must be last. Command-line run settings overrides take precedence over values from a file passed with `/Settings`.

```cmd
vstest.console.exe test.dll -- MSTest.MapInconclusiveToFailed=True MSTest.DeploymentEnabled=False
```

The same syntax works with `dotnet test` (use `dotnet test -- MSTest.MapInconclusiveToFailed=True`).

You can set **TestRunParameters** from the command line:

```cmd
vstest.console.exe test.dll -- TestRunParameters.Parameter(name="myParam", value="value")
```

Shell quoting rules differ. In Command Prompt, escape quotation marks as needed. In PowerShell 7.3 and later, native command argument handling supports this syntax more directly; in earlier PowerShell versions, or when `$PSNativeCommandArgumentPassing` is set to `legacy`, use the `--%` stop-parsing token. In Bash, escape characters such as parentheses, quotation marks, spaces, and semicolons.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph should also include the rules for unix shells, using zsh as the example.

@azat-msft azat-msft Jul 15, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a paragraph covering unix shell quoting with zsh


In zsh (the default shell on macOS), use the same escaping as Bash: escape quotation marks, spaces, and semicolons. Because zsh also treats unquoted parentheses as globbing and array syntax, always escape or quote the parentheses in `TestRunParameters.Parameter(...)`. For example:

```zsh
vstest.console.exe test.dll -- TestRunParameters.Parameter\(name=\"myParam\",\ value=\"value\"\)
```

Parameter values can contain semicolons and other special characters, such as connection strings, but the shell must pass them through literally. For complex values, consider using a *.runsettings* file instead:

```xml
<RunSettings>
<TestRunParameters>
<Parameter name="connectionString" value="Server=localhost;Database=mydb;Trusted_Connection=True" />
</TestRunParameters>
</RunSettings>
```

For more command-line examples and shell-specific quoting details, see [Passing runsettings arguments through the command line](https://github.com/microsoft/vstest/blob/main/docs/RunSettingsArguments.md).

## The *.runsettings file

The *.runsettings file is an XML file that contains different configuration elements within the **RunSettings** element. The sections that follow detail the different elements. For a complete sample, see [Example *.runsettings file](#example-runsettings-file).
Expand Down
10 changes: 6 additions & 4 deletions docs/test/vstest-console-options.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: VSTest.Console.exe command-line options
description: Learn about the VSTest.Console.exe command-line tool that runs tests. This article includes the General command-line options.
ms.date: 02/28/2025
ms.date: 07/13/2026
ms.topic: reference
helpviewer_keywords:
- vstest.console.exe
Expand Down Expand Up @@ -38,20 +38,20 @@ The following table lists all the options for *VSTest.Console.exe* and short des
|**/TestAdapterPath:[*path*]**|Forces the *vstest.console.exe* process to use custom test adapters from a specified path (if any) in the test run.<br />Example: `/TestAdapterPath:[pathToCustomAdapters]`|
|**/Platform:[*platform type*]**|Forces the given platform to be used, instead of the platform determined from the current runtime. This option is able to force only x86, and x64 platforms on Windows. The ARM option is broken and will result in x64 on most systems.<br />Do NOT specify this option to run on runtimes that aren't in the list of valid values such as ARM64.<br />Valid values are x86, x64, and ARM.<br />
|**/Framework: [*framework version*]**|Target .NET version to be used for test execution.<br />Example values are `Framework35`, `Framework40`, `Framework45`, `FrameworkUap10`, `.NETCoreApp,Version=v1.1`.<br />TargetFrameworkAttribute is used to automatically detect this option from your assembly, and defaults to `Framework40` when the attribute isn't present. You must specify this option explicitly if you remove the [TargetFrameworkAttribute](/dotnet/api/system.runtime.versioning.targetframeworkattribute) from your .NET Core assemblies.<br />If the target framework is specified as **Framework35**, the tests run in CLR 4.0 "compatibility mode".<br />Example: `/Framework:framework40`|
|**/TestCaseFilter:[*expression*]**|Run tests that match the given expression.<br /><Expression\> is of the format <property\>=<value\>[\|<Expression\>].<br />Example: `/TestCaseFilter:"Priority=1"`<br />Example: `/TestCaseFilter:"TestCategory=Nightly|FullyQualifiedName=Namespace.ClassName.MethodName"`<br />The **/TestCaseFilter** command-line option can't be used with the **/Tests** command-line option. <br />For information about creating and using expressions, see [TestCase filter](https://github.com/Microsoft/vstest-docs/blob/main/docs/filter.md).|
|**/TestCaseFilter:[*expression*]**|Run tests that match the given expression.<br /><Expression\> is of the format <property\>=<value\>[\|<Expression\>].<br />Example: `/TestCaseFilter:"Priority=1"`<br />Example: `/TestCaseFilter:"TestCategory=Nightly|FullyQualifiedName=Namespace.ClassName.MethodName"`<br />The **/TestCaseFilter** command-line option can't be used with the **/Tests** command-line option. <br />For information about creating and using expressions, see [TestCase filter](https://github.com/microsoft/vstest/blob/main/docs/filter.md).|
|**/?**|Displays usage information.|
|**/Logger:[*uri/friendlyname*]**|Specify a logger for test results. Specify the parameter multiple times to enable multiple loggers.<br />Example: To log results into a Visual Studio Test Results File (TRX), use<br />**/Logger:trx**<br />**[;LogFileName=\<Defaults to unique file name>]**<br />For more information, see [Logging example](#logging-example).|
|**/ListTests:[*file name*]**|Lists discovered tests from the given test container.<br />Note: The `/TestCaseFilters` option has no effect when listing tests; it only controls which tests get run.|
|**/ListDiscoverers**|Lists installed test discoverers.|
|**/ListExecutors**|Lists installed test executors.|
|**/ListLoggers**|Lists installed test loggers.|
|**/ListSettingsProviders**|Lists installed test settings providers.|
|**/Blame**|Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash. When a crash is detected, it creates a sequence file in `TestResults/<Guid>/<Guid>_Sequence.xml` that captures the order of tests that were run before the crash. For more information, see [Blame data collector](https://github.com/Microsoft/vstest-docs/blob/main/docs/extensions/blame-datacollector.md).|
|**/Blame**|Runs the tests in blame mode. This option is helpful in isolating problematic tests that cause the test host to crash. When a crash is detected, it creates a sequence file in `TestResults/<Guid>/<Guid>_Sequence.xml` that captures the order of tests that were run before the crash. For more information, see [Blame data collector](https://github.com/microsoft/vstest/blob/main/docs/extensions/blame-datacollector.md).|
|**/Diag:[*file name*]**|Writes diagnostic trace logs to the specified file.|
|**/ResultsDirectory:[*path*]**|Test results directory will be created in specified path if not exists.<br />Example: `/ResultsDirectory:<pathToResultsDirectory>`|
|**/ParentProcessId:[*parentProcessId*]**|Process ID of the Parent Process responsible for launching current process.|
|**/Port:[*port*]**|The Port for socket connection and receiving the event messages.|
|**/Collect:[*dataCollector friendlyName*]**|Enables data collector for the test run. [More information](https://github.com/Microsoft/vstest-docs/blob/main/docs/analyze.md).|
|**/Collect:[*dataCollector friendlyName*]**|Enables data collector for the test run. [More information](https://github.com/microsoft/vstest/blob/main/docs/analyze.md).|

> [!TIP]
> The options and values aren't case-sensitive.
Expand Down Expand Up @@ -119,6 +119,8 @@ In PowerShell, you need to use quotes:
vstest.console.exe myTestFile.dll /logger:"console;verbosity=detailed"
```

For the full list of available loggers, as well as instructions for authoring your own logger, see [Reporting test results](https://github.com/microsoft/vstest/blob/main/docs/report.md) in the vstest repository.

## UWP example

For UWP, the appxrecipe file must be referenced instead of a DLL.
Expand Down