VSTest.Console.exe command-line options

Applies to: yesVisual Studio noVisual Studio for Mac

VSTest.Console.exe is the command-line tool to run tests. You can specify several options in any club on the command line. These options are listed in General control-line options.

Notation

The MSTest adapter in Visual Studio likewise works in legacy mode (equivalent to running tests with mstest.exe) for compatibility. In legacy mode, it tin can't take advantage of the TestCaseFilter feature. The adapter can switch to legacy mode when a testsettings file is specified, forcelegacymode is set to true in a runsettings file, or by using attributes such every bit HostType.

To run automated tests on an ARM architecture-based automobile, you must employ VSTest.Console.exe.

Open up Developer Command Prompt to utilise the command-line tool, or you lot can notice the tool in %Program Files(x86)%\Microsoft Visual Studio\<version>\<edition>\common7\ide\CommonExtensions\<Platform | Microsoft>.

General control-line options

The following table lists all the options for VSTest.Console.exe and curt descriptions of them. You can come across a like summary past typing VSTest.Console/? at a command line.

Selection Description
[test file names] Run tests from the specified files. Separate multiple test file names with spaces.
Examples: mytestproject.dll, mytestproject.dll myothertestproject.exe
/Settings:[file proper noun] Run tests with additional settings such equally data collectors. For more information, run into Configure unit tests using a .runsettings file
Instance: /Settings:local.runsettings
/Tests:[test proper name] Run tests with names that comprise the provided values. To provide multiple values, carve up them by commas.
Example: /Tests:TestMethod1,testMethod2
The /Tests command-line option cannot exist used with the /TestCaseFilter control-line selection.
/Parallel Specifies that the tests exist executed in parallel. By default, up to all available cores on the machine tin exist used. Yous tin configure the number of cores to employ in a settings file.
/Enablecodecoverage Enables information diagnostic adapter CodeCoverage in the test run.
Default settings are used if not specified using settings file.
/InIsolation Runs the tests in an isolated procedure.
This isolation makes the vstest.console.exe process less probable to be stopped on an error in the tests, but tests might run slower.
/UseVsixExtensions This option makes the vstest.console.exe process apply or skip the VSIX extensions installed (if any) in the test run.
This option is deprecated. Starting from the next major release of Visual Studio this option may be removed. Move to consuming extensions made available as a NuGet bundle.
Instance: /UseVsixExtensions:true
/TestAdapterPath:[path] Forces the vstest.panel.exe process to use custom examination adapters from a specified path (if any) in the examination run.
Example: /TestAdapterPath:[pathToCustomAdapters]
/Platform:[platform blazon] Forces the given platform to exist used, instead of the platform determined from the electric current runtime. This pick is able to force only x86, and x64 platforms on Windows. The ARM pick is broken and will result in x64 on almost systems.
Do Non specify this pick to run on runtimes that are non in the list of valid values such as ARM64.
Valid values are x86, x64, and ARM.
/FailWhenNoTestsFound: [boolean] When prepare to true, returns non-nada value if no tests are discovered.
/Framework: [framework version] Target .Net version to be used for test execution.
Example values are Framework35, Framework40, Framework45, FrameworkUap10, .NETCoreApp,Version=v1.one.
TargetFrameworkAttribute is used to automatically discover this option from your assembly, and defaults to Framework40 when the attribute is not present. You must specify this selection explicitly if you remove the TargetFrameworkAttribute from your .Internet Core assemblies.
If the target framework is specified as Framework35, the tests run in CLR 4.0 "compatibility fashion".
Instance: /Framework:framework40
/TestCaseFilter:[expression] Run tests that match the given expression.
<Expression> is of the format <holding>=<value>[|<Expression>].
Example: /TestCaseFilter:"Priority=i"
Example: /TestCaseFilter:"TestCategory=Nightly|FullyQualifiedName=Namespace.ClassName.MethodName"
The /TestCaseFilter command-line option cannot be used with the /Tests command-line option.
For information well-nigh creating and using expressions, see TestCase filter.
/? Displays usage data.
/Logger:[uri/friendlyname] Specify a logger for test results. Specify the parameter multiple times to enable multiple loggers.
Example: To log results into a Visual Studio Test Results File (TRX), utilise
/Logger:trx
[;LogFileName=<Defaults to unique file name>]
/ListTests:[file name] Lists discovered tests from the given test container.
/ListDiscoverers Lists installed test discoverers.
/ListExecutors Lists installed exam 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 examination 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 data, see Blame data collector.
/Diag:[file name] Writes diagnostic trace logs to the specified file.
/ResultsDirectory:[path] Examination results directory will exist created in specified path if not exists.
Example: /ResultsDirectory:<pathToResultsDirectory>
/ParentProcessId:[parentProcessId] Procedure ID of the Parent Procedure responsible for launching current procedure.
/Port:[port] The Port for socket connexion and receiving the effect letters.
/Collect:[dataCollector friendlyName] Enables data collector for the exam run. More information.

Tip

The options and values are not case-sensitive.

Examples

The syntax for running vstest.console.exe is:

vstest.console.exe [TestFileNames] [Options]

Past default, the command returns 0 when it exits normally, even if no tests are discovered. If you desire to return a non-zero value if no tests are discovered, use /FailWhenNoTestsFound.

The following command runs vstest.console.exe for the examination library myTestProject.dll:

              vstest.panel.exe myTestProject.dll                          

The following command runs vstest.console.exe with multiple exam files. Separate test file names with spaces:

              vstest.panel.exe myTestFile.dll myOtherTestFile.dll                          

The following control runs vstest.console.exe with several options. It runs the tests in the myTestFile.dll file in an isolated process and uses settings specified in the Local.RunSettings file. Additionally, it only runs tests marked "Priority=i", and logs the results to a .trx file.

              vstest.console.exe myTestFile.dll /Settings:Local.RunSettings /InIsolation /TestCaseFilter:"Priority=ane" /Logger:trx                          

The post-obit control runs vstest.console.exe with the /arraign option for the test library myTestProject.dll:

              vstest.console.exe myTestFile.dll /arraign                          

If a test host crash happened, the sequence.xml file is generated. The file contains fully qualified names of the tests in their sequence of execution upwardly to and including the specific exam that was running at the fourth dimension of the crash.

If there is no examination host crash, the sequence.xml file will non be generated.

Example of a generated sequence.xml file:

              <?xml version="1.0"?> <TestSequence>   <Test Name="TestProject.UnitTest1.TestMethodB" Source="D:\repos\TestProject\TestProject\bin\Debug\TestProject.dll" />   <Test Name="TestProject.UnitTest1.TestMethodA" Source="D:\repos\TestProject\TestProject\bin\Debug\TestProject.dll" /> </TestSequence>                          

UWP example

For UWP, the appxrecipe file must exist referenced instead of a DLL.

              vstest.console.exe /Logger:trx /Platform:x64 /framework:frameworkuap10 UnitTestsUWP\bin\x64\Release\UnitTestsUWP.build.appxrecipe