I've been having a first go at using opencover for a current project, and have just got it working with my mstest project. I am having a problem though, in that the opencover output xml appears to trying to analyse the same assembly twice. Also worth note is that one of the analysis' shows 0% code coverage (which is wrong), whereas the other is more like 85% (which is correct).
My opencover command looks like:
"opencover.console.exe" -register:user -target:"C:\Program Files (x86)\Microsoft visual Studio 10.0\Common7\IDE\mstest.exe" -output:"C:\temp\coverage.xml" -targetargs:"/testcontainer:MyTestAssembly.dll" -filter:+[MyAssembly]MyNamespace.MyClassName
This is referring to a single assembly, and a single class in that assembly. However, the xml output has 2 module sectons, with the same hash. Interestingly, the first module has a FullName pointing at the assembly in my "\bin\Debug\MyAssembly.dll" folder, whereas the second one points at the output assembly in "C:\temp\TestResults...\Out\MyAssembly.dll".
Any ideas?
Matt
You need to use the -mergebyhash switch this is documented in the WIKI/USAGE
This is because mstest opens the assembly twice in different locations; once in its original location and then again in a test folder.
This option forces opencover to compare assemblies by a file hash and reuse the identifiers for sequence points for previously loaded assemblies. You may also need to use -targetdir, if it can't locate the PDBs, to point to the folder with them in but it usually does find them without extra help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With