从Windows命令行运行MSTests

时间:2012-09-06 16:32:50

标签: .net visual-studio-2010 visual-studio unit-testing mstest

我有5个解决方案都使用MSTest,我希望在根文件夹中有一个cmd文件来运行所有测试

所以我想从命令行调用MsTests运行器

\Solution1\Tests\Debug\Test.dll
...
\Solution5\Tests\Debug\Test.dll

任何人都知道如何做到这一点?

3 个答案:

答案 0 :(得分:14)

这在MSDN上有详细说明:How to: Run Automated Tests from the Command Line Using MSTest

基本上,你可以这样做:

MSTest /testcontainer:\Solution1\Tests\Debug\Test.dll

答案 1 :(得分:1)

我从此线程得到了答案:https://gist.github.com/leniel/2438148

只需运行以下命令即可使用MSTest /testcontainer

运行测试用例
C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE>MSTest /testcontainer:"C:\project-name\projectTestSolutionFolder\bin\Release\ProjectTest.dll"

答案 2 :(得分:0)

如果使用 .Net Core:

dotnet test ./nameoftest.dll

在测试所在的文件夹中。

有关命令行选项,请参阅: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test

相关问题