Question

I am having a problem when trying to run a VS10 test suite through OpenCover, using mstest as my target application. Running the tests directly with MsTest works with this command:

"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"

However, when trying to run the same command under OpenCover, like this:

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

it fails, with the following error, regarding the .vsmdi.trx file (which I gather should be created by MsTest after the tests run):

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

So, basically, it complains that it cannot find the results file, before running the tests, but that file is supposed to be created at the end of the run.

Might this be an issue related to OpenCover, as the same params work when running directly with mstest?

I checked my paths and they all work out, even the one in the error is the path where the file should be generated by mstest.

Thanks.

Was it helpful?

Solution

It looks like you may need to escape your quotes when passing your data via targetargs

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

becomes

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

as detailed in the wiki on handling spaces.

Alternatively put your command to execute your tests in a cmd/bat file and then use opencover to execute that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top