How to run ALL tests in my solution using command line MSTest.exe?

后端 未结 4 750
挽巷
挽巷 2020-12-14 15:20

According to MSDN here and discussed here, we can use MSTest.exe to run tests from command line - which is sweet and faster than running within the IDE (especia

相关标签:
4条回答
  • 2020-12-14 15:22

    I accomplished this using the testmetadata argument and pointing it to my .vsmdi file.

    As explained here.

    E.g.:

    mstest /testmetadata:mySolution.vsmdi
    

    However note that testmetadata can be more fragile (e.g. empty test lists combined with the Ignore attribute cause "Specified cast is not valid"). Creating a batch with all DLLs containing test classes could be more reliable alternative.

    0 讨论(0)
  • 2020-12-14 15:35

    I needed the same thing, without wanting to install anything or generate vsmdi files, so I came up with this PowerShell script, below. It runs ALL tests in one command on a folder and it's subfolders (not solution, but fine for me).

    Feel free to suggest how to make this script more elegant:

    $x = ""; dir *\bin\*test*.dll -Recurse | foreach { $x += "/testcontainer:""$_"" " }; iex "mstest $x"
    

    Instructions:

    • Add path to mstest.exe via Environment variables variable PATH, otherwise just replace mstest with its full path in the PowerShell script above.

    • Open PowerShell, paste the command.
    • Modify *\bin\*test*.dll to meet your needs. In current script it will get all DLLs in the bin folder recursively, containing substring "test" in the filename.
    • Run the command!
    0 讨论(0)
  • 2020-12-14 15:37

    Just use:

    mstest.exe /testcontainer:yourTests.dll /resultsfile:res.trx
    

    and it will run all tests in that assembly, and spit out the results in the specified file.

    0 讨论(0)
  • 2020-12-14 15:45

    You might want to have a look at the Gallio.Echo test runner which comes with the Gallio test automation platform. It's a free (OSS) package with many convenient reporting tools and test runners and which supports most the existing test frameworks (MbUnit, NUnit, MSTest, xUnit, etc.)

    alt text

    More specifically, Gallio.Echo is a versatile command line test runner. You can specify a list of test assemblies, various filters, and many extra options. Gallio consolidates the test results in a single report (Xml, Html, Zip, etc.)

    0 讨论(0)
提交回复
热议问题