在OpenCover下运行mstest时,我收到有关.vsmdi.trx文件的错误

时间:2013-10-01 09:14:26

标签: visual-studio-2010 mstest opencover

尝试通过OpenCover运行VS10测试套件时遇到问题,使用mstest作为我的目标应用程序。 使用MsTest直接运行测试可以使用以下命令:

"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" /resultsfile:"<application_root_path>\UnitTestResults\MyProject.vsmdi.trx" /testmetadata:"MyProject.vsmdi" /testlist:"ServiceTests" /testlist:"DatabaseTests"

但是,尝试在OpenCover下运行相同的命令时,如下所示:

OpenCover\Opencover.console.exe -register:user -target:"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" -targetargs:"/resultsfile:"<application_root_path>\UnitTestResults\MyProject.vsmdi.trx" /testmetadata:"MyProject.vsmdi" /testlist:"ServiceTests" /testlist:"DatabaseTests"" -output:<application_root_path>\UnitTestResults\Coverage

关于.vsmdi.trx文件(我收集的应该是由MsTest 测试运行之后)创建后,会出现以下错误:

Error occurred while loading document '<application_root_path>\UnitTestResults\MyProject.vsmdi.trx'.
Code:   0x800c0006
The system cannot locate the object specified.

所以,基本上,它抱怨它在运行测试之前无法找到结果文件,但该文件应该在运行结束时创建。

这可能是与OpenCover相关的问题,因为直接使用mstest运行时,相同的参数是否有效?

我检查了我的路径并且它们都运行了,即使是错误中的那个也是mstest应该生成文件的路径。

感谢。

1 个答案:

答案 0 :(得分:1)

看起来您可能需要在通过targetargs传递数据时转义引号

-targetargs:"/resultsfile:"<application...""

变为

-targetargs:"/resultsfile:\"<application...\""

详见wiki on handling spaces

或者将命令放在cmd / bat文件中执行测试,然后使用opencover执行它。