0

I'm trying to run OpenCover with MSTest on Windows Server 2008 R2 machine and always get empty results:

c:\OpenCover>OpenCover.Console.exe -register:user -target:"C:\Program Files (x86 )\Microsoft Visual Studio 11.0\Common7\IDE\MsTest.exe" -targetdir:"c:\MyApp\bin" -targetargs: /testcontainer:"C:\MyApp\Tests\bin\UnitTests.dll" -output:c:\cover.xml

Microsoft (R) Test Execution Command Line Tool Version 11.0.51106.1

Copyright (c) Microsoft Corporation. All rights reserved.

Please specify tests to run, or specify the /publish switch to publish results.

For switch syntax, type "MSTest /help"

Committing...

No results - no assemblies that matched the supplied filter were instrumented this could be due to missing PDBs for the assemblies that match the filter please review the output file and refer to the Usage guide (Usage.rtf)

The PDB files exist in the specified folder and the profiler DLLs are registered using regsvr (both x64 and x86). Microsoft Visual C++ 2010 Redistributable Package is installed. .NET framework 3.5, 4.5 installed. I've tried to run it with and without administrator permissions...

At the same time it works perfectly on my win7 x64 machine with VS 2012 installed so I suppose I've missed some dependancies or this is a security issue.

After removing quotes and spaces I receive a better result but still without code coverage:

enter image description here

msaruyev
  • 255
  • 2
  • 10

1 Answers1

2

Which version of OpenCover?

The latest version should not require "Microsoft Visual C++ 2010 Redistributable Package"

If you have registered the assemblies using resvr32 then you do not need the -register:user switch.

As it does not look like you tests are running it looks like the parameters you are passing through are incorrect (a space between "-targetargs: /target...", try:

"-targetargs:/testcontainer:C:\MyApp\Tests\bin\UnitTests.dll"

Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56
  • Oh no...I've spent hours because of this space in my args. Thank you so much. Now it seems to work but I still get an error at the end of the OpenCover execution. The XML file is generated but after the "Total Results file: C:\bla-bla 2013-02-06 10_30_30.trx Test Settings: Default Test Settings Committing..." I still get this error: No results - no assemblies that matched and so on – msaruyev Feb 06 '13 at 08:42
  • As I see from the XML the PDBs are missing but all the required PDB files are in the target directory – msaruyev Feb 06 '13 at 08:51
  • try removing the quotes or wrap the whole argument `"-targetdir:..."` alternatively add the mstest argument `/noislation` to the targetargs – Shaun Wilde Feb 06 '13 at 11:37
  • I've copied the files and folders to my local machine and the same command runs successfuly. It seems there is something else except the spaces and quotes. – msaruyev Feb 06 '13 at 14:00
  • Can you show the folder where the pdbs are stored and the full command line used and not edited portions. – Shaun Wilde Feb 06 '13 at 22:39
  • I've copied all the assemblies with pdbs into the "test" folder on drive C on both win7 and win2008 machines and ran the following command: OpenCover.Console.exe -target:"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MsTest.exe" -targetdir:c:\test -targetargs:/testcontainer:"c:\test\UnitTests.dll" -output:c:\cover.xml. On win7 machine I do receive the expected results while on win2008 I remain with the same error. – msaruyev Feb 07 '13 at 06:36
  • Something strange, but after I've unregistered and registered again the profiler dlls the opencover started to work. Thank you so much for your help. I believe I'll open more questions here as we are trying to integrate it to our TFS2012 build process. – msaruyev Feb 07 '13 at 07:00