MsTest |
Top Previous Next |
This command is only available to users that hold a Pro License
The MsTest command allows you to run Microsoft testing framework Unit Tests.
Command Syntax
MsTest:[ExePath],[TestContainer],[ResultsFile],[TestName(s)]
The colon after the command and the commas between parameters are compulsory. Any additional spaces or characters will cause an error to be thrown. The command itself is not case sensitive, but parameters may be depending on the operating system and locale.
Parameters:
ExePath: The fully qualified path identifying the location of MSTest.exe. The parameter may optionally be surrounded by quotation marks if one or more spaces are included in the path and file name. It is good practice to include the quotation marks in any case, so that it reduces the risk of error when writing scripts.
TestContainer: The fully qualified path and file name of the test container. The test container is a file that contains the tests you want to run. For example, for ordered tests, the test container is the .orderedtest file that defines the ordered test. For unit tests, it is the assembly built from the test project that contains the unit test source files. The parameter may optionally be surrounded by quotation marks if one or more spaces are included in the path and file name. It is good practice to include the quotation marks in any case, so that it reduces the risk of error when writing scripts. ResultsFile: The fully qualified path and file name of the .TRX file to which the test results should be saved. The parameter may optionally be surrounded by quotation marks if one or more spaces are included in the path and file name. It is good practice to include the quotation marks in any case, so that it reduces the risk of error when writing scripts. If you do not wish to create a results file, leave the parameter empty. TestName(s): Zero or more strings representing the names of specific tests to be run which must exist in the TestContainer. Multiple test names are supported but must be separated Pipe characters. If no preprocessor directives are required leave the parameter empty.
All comma separators are compulsory as are the ExePath and TestContainer parameters. If either of those parameters is missing or invalid or the incorrect number of comma separators are provided an error will be thrown.
Examples:
Run all tests in the container, no results file and no test names:
MsTest:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE","C:\Source\MyAppTests\MyAppTests.dll",,
All parameters specified:
MsTest:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE","C:\Source\MyAppTests\MyAppTests.dll","C:\MyAppTests\MyAppTests.trx",TestMethod1|TestMethod12|TestMethod13
See Also: MsBuild DotNetBuild |