0

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.

nestedloop
  • 2,596
  • 23
  • 34

1 Answers1

1

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.

Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56
  • Hi Shaun, and thanks for the quick response. Escaping the quotes did not work, as this is done from a python script, and they were already properly placed (doubles in singles '""'). More to the point, my question would be if there is any instance that you know of where target args might be used differently (especially for target mstest) when ran through OpenCover, than when running the target directly. – nestedloop Oct 01 '13 at 12:50
  • Your escaping may work in python to print a quote but are they escaped on the command line i.e. what do you actually execute on the command line? Perhaps you need \'""' such that \" is printed. Is part of what you put on the command line or some obfuscation so we do not know the actual path names? If the former then you may need to translate that first because opencover nor the OS will understand it. – Shaun Wilde Oct 02 '13 at 02:14
  • The commands I posted in my question are what gets to the command line, with the exception of which stands here as a placeholder for a variable path (no spaces in it), as this happens on a build machine. – nestedloop Oct 02 '13 at 15:17
  • Then as I said before the quotes on the command line appear to be escaped incorrectly - if the quotes that are inside other quotes are not escaped properly then they will be incorrectly passed to opencover and in turn incorrectly passed on to your application. – Shaun Wilde Oct 02 '13 at 23:34