Export (0) Print
Expand All

How to: Obtain Command-Line Test Results

You can use the executable program MSTest.exe to run tests from a command line. MSTest.exe automatically displays a run summary to the command prompt window.

It also automatically saves test results to disk. In the Summary section of the results output screen, MSTest displays the name of the automatically generated results file. For example:

Results file: D:\temp\test\TestProject3\TestProject3\TestResults\thisuser@ThisUser-32G 9_24_2012 1_27_37 PM.trx

If you prefer, you can explicitly save test results to a file that you name. And if your Visual Studio client session is connected to a Team Foundation Server, you can publish results to the database for your team project collection. Both options are described in the following procedures.

Note Note

For information about publishing test data from Visual Studio, see Command-Line Options for Publishing Test Results.

To save command-line test results to a specific file

  • Using the MSTest program, run tests.

    Use the /resultsfile:[file name] option to specify the name of a file in which you want to save test results. For example:

    MSTest /testmetadata:Bank.vsmdi /resultsfile:BanktestResults.trx

    Note Note

    Test results files need the .trx extension to function correctly, but the MSTest command does not automatically supply that extension. Therefore, we recommend that you include the .trx extension when you run this command.

    For more information about the options that you can use with the MSTest program, see MSTest.exe Command-Line Options.

To publish command-line test results to the database for the team project collection

  • Using the MSTest program, run tests.

    Note Note

    You can publish test results to the database for the team project collection only if connected to a Team Foundation Server and if you have Team Explorer installed. For information about how to connect to Team Foundation Server, see Connect to Team Projects in Team Foundation Server.

    Several command-line options pertain to publishing test results. You use them in combination, depending on which test results you want to publish. Five of these options are required: /publish, /publishbuild, /teamproject, /platform, and /flavor. One is optional: /publishresultsfile.

    • Publish current test results. To run tests and publish their results immediately, use options that specify the tests to run and the required options for publishing. For example:

      MSTest /testcontainer:test.dll /publish:http://ourtfsmachine:8080 /teamproject:ProjectName /publishbuild:BuildNumber01 /platform:AnyCpu /flavor:Release

    • Publish past test results. To publish the results of tests that were run previously, omit any command-line options that specify tests to run -- such as /testcontainer: and /testmetadata:, because you are not running tests. For example:

      MSTest /publishresultsfile:testResult.trx /publish:http://ourtfsmachine:8080 /teamproject:ProjectName /publishbuild:BuildNumber01 /platform:AnyCpu /flavor:Release

      For more information about how to use these options, see MSTest.exe Command-Line Options.

Show:
© 2014 Microsoft