如何使用命令行MSTest.exe在我的解决方案中运行所有测试?

如何使用命令行MSTest.exe在我的解决方案中运行所有测试?

问题描述:

根据MSDN 此处并讨论了这里,我们可以使用 MSTest.exe 从命令行运行测试 - 这是甜美的,比在IDE中运行(尤其是慢,如果你正在一个像我这样的大解决方案)。

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 (especially slow if you are working on a big solution like me).

我的问题是如何使用 MSTest.exe 在我的解决方案中运行所有测试?该命令只有 / test 选项可过滤在 / container $ c $中指定的一个程序集中的测试c>选项。我只能想到调用这个命令N次,因为我可以在我的解决方案(!?)所有的N测试程序集。此外,运行后的结果是每个程序集的基础,所以不容易得到什么测试失败/

My question is how can I use MSTest.exe to run all tests in my solution? The command only have the /test option to filter the tests in one assembly specified in /container option. I only can think of calling this command N times given that I can have all the N test assembly in my solution (!?) Moreover, the results after run are per-assembly basics so that it's not easy to get what tests were failed/passed.

如果你知道更好的方法,请分享!谢谢!

If you know a better way, please share! Thank you!

我使用 testmetadata 它到我的.vsmdi文件。

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

如解释此处

例如:

mstest /testmetadata:mySolution.vsmdi

testmetadata 可能更脆弱(例如空白测试列表结合Ignore属性原因指定的转换无效)。
创建一个包含所有包含测试类的DLL的批处理可能是更可靠的替代方法。

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.