Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No result with opencover + xunit

I was trying to use OpenCover (downloaded today) to get coverage of my tests. Here is the command line I've used :

OpenCover.Console.exe -target:"c:\Programmes2\xunit\xunit.console.clr4.x86.exe" -targetargs:"""C:\Sources\Project\BackOffice.Tests\bin\Debug\BackOffice.Tests.dll"" /noshadow " -output:bo.coverage.xml -targetdir:"C:\Sources\Project\BackOffice.Tests\bin\Debug" -filter:+[*]*

And here is the output I get

xUnit.net console test runner (32-bit .NET 4.0.30319.269)
Copyright (C) 2007-11 Microsoft Corporation.

xunit.dll:     Version 1.9.0.1566
Test assembly: C:\Sources\Project\BackOffice.Tests\bin\Debug\BackOffice.Tests.dll

31 total, 0 failed, 0 skipped, took 2.760 seconds
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 generated report is always the same:

<?xml version="1.0" encoding="utf-8"?>
<CoverageSession xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Modules />
</CoverageSession>

A bit more context : The PDB's are present in the target folder, I'm running the Command prompt as an administrator. The project tested is an .net 4/mvc 3 application. My computer is running windows 7/32bits. On that topic, not sure if that's relevant in any way, but the x86 folder in the is empty, even if I force the target plateform to be x86.

Also, when I try to register the OpenCover.Profiler.dll with regsvr32, I get an error that says that the dll may not be compatible with my windows version.

If I try to user the -register or the -register:user parameters, I get an exception:

An exception occured: Failed to register(user:True,register:True,is64:False):3 the profiler assembly; you may want to look into permissions or using the -register:user option instead. C:\Windows\system32\regsvr32.exe /s  /n /i:user "C:\Sources\Opencover\sawilde-opencover-be6e491\main\bin\Debug\x86\OpenCover.Profiler.dll"
stack:    
    à OpenCover.Framework.ProfilerRegistration.ExecuteRegsvr32(Boolean userRegistration, Boolean register, Boolean is64) dans C:\Sources\Opencover\sawilde-opencover-be6e491\main\OpenCover.Framework\ProfilerRegistration.cs:ligne 59
    à OpenCover.Framework.ProfilerRegistration.ExecuteRegsvr32(Boolean userRegistration, Boolean register) dans C:\Sources\Opencover\sawilde-opencover-be6e491\main\OpenCover.Framework\ProfilerRegistration.cs:ligne 45
    à OpenCover.Framework.ProfilerRegistration.Register(Boolean userRegistration) dans C:\Sources\Opencover\sawilde-opencover-be6e491\main\OpenCover.Framework\ProfilerRegistration.cs:ligne 31
    à OpenCover.Console.Program.Main(String[] args) dans C:\Sources\Opencover\sawilde-opencover-be6e491\main\OpenCover.Console\Program.cs:ligne 82

I also tried with a DLL project (.net4) tested by a different project (xunit also), with the same (lack of) result.

Any help appreciated !

like image 302
Sebastien F. Avatar asked May 24 '12 10:05

Sebastien F.


1 Answers

Downloading the release package solved the exception from the register parameter. But running the same command line generated multiple errors of this kind:

BackOffice.Tests.HomeControllerShould.Redirect_To_Action_Feed_Index [FAIL]
   System.MissingMethodException : Méthode introuvable : 'Void     System.CannotUnloadAppDomainException.SafeVisited(Int32)'.
   Stack Trace:
      à BackOffice.Tests.HomeControllerShould..ctor()

with this result:

31 total, 31 failed, 0 skipped, took 0.241 seconds
Committing...
Visited Classes 0 of 44 (0)
Visited Methods 0 of 183 (0)
Visited Points 0 of 1352 (0)
Visited Branches 0 of 322 (0)

==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 0 of 53 (0)
Alternative Visited Methods 0 of 268 (0)

After looking around for similar issues, I found this issue on github and tried the -oldStyle parameter. It solved mine.

@Shaun Wilde, if by any chance you see this question again, could you tell us if it's the recommended way to solve it and if we lose something from using it against the "normal" way (I would also suggest adding this parameter to the documentation page

like image 148
Sebastien F. Avatar answered Oct 20 '22 09:10

Sebastien F.