Search code examples
asp.netpowershellxunitopencover

OpenCover showing no result asp net core 461


I'm trying to get OpenCover working for our asp net core project, targeting full framework 461. We are using XUnit as the testing framework. However when I run my powershell script, the result only shows coverage on the test classes in my test folders and not coverage on the classes inside source folder.

How do I get coverage on those files?

My solution is structured like this src/API and test/API.UnitTests

The important port my script looks like this:

&$openCoverPath\OpenCover.Console.exe `
    -target:$xunitPath\xunit.console.x86.exe `
    -targetargs:".\test\API.UnitTests\bin\Debug\net461\API.UnitTests.dll -noshadow -nologo" `
    -register:user `
    -oldstyle `
    -mergeoutput `
    -hideskipped:File `
    -searchdirs:".\test\API.UnitTests\bin\Debug\net461\" `
    -output:$coverageReportFile

# Generate HTML report from results with ReportGenerator
&$reportGeneratorPath\ReportGenerator.exe `
    -reports:$coverageReportFile `
    -targetdir:$coverageReportFolder

Solution

  • <DebugType>Full</DebugType>
    

    in the api csproj file did the trick.