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



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

"C:Program FilesMicrosoft Visual Studio 10.0Common7IDEMSTest.exe" /resultsfile:"<application_root_path>UnitTestResultsMyProject.vsmdi.trx" /testmetadata:"MyProject.vsmdi" /testlist:"ServiceTests" /testlist:"DatabaseTests"

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

OpenCoverOpencover.console.exe -register:user -target:"C:Program FilesMicrosoft Visual Studio 10.0Common7IDEMSTest.exe" -targetargs:"/resultsfile:"<application_root_path>UnitTestResultsMyProject.vsmdi.trx" /testmetadata:"MyProject.vsmdi" /testlist:"ServiceTests" /testlist:"DatabaseTests"" -output:<application_root_path>UnitTestResultsCoverage

它失败,并出现以下错误,关于 .vsmdi.trx 文件(我收集的文件应该由 MsTest 在测试运行创建):

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

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

这可能是与 OpenCover 相关的问题,因为当直接使用 mstest 运行时,相同的参数可以工作?

我检查了我的路径,它们都解决了,即使是错误中的路径也是 mstest 应该生成文件的路径。

谢谢。

看起来在通过目标参数传递数据时可能需要转义引号

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

成为

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

如 Wiki 中关于处理空格的内容中所述。

或者,将您的命令以在cmd/bat文件中执行测试,然后使用opencover执行该命令。

最新更新