Closed lifemanship closed 4 years ago
That's the intended behavior. Coverage is grouped by class and not by file. Therefore a partial class is handled as a single element and shows all corresponding files.
I prepared simple test solution which will show difference between code coverage in html format after conversion from Cobertura
and OpenCover
formats.
TestCoveragePartialClasses.zip
The Coverage.zip contains: Coverage.zip
UnitTests.xml\Cobertura.UnitTests.TestCoveragePartialClasses.results.xml - coverage created by dotnet with options dotnet test TestCoveragePartialClasses.sln --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
UnitTests.xml\OpenCover.UnitTests.TestCoveragePartialClasses.results.xml - coverage created by dotnet with options dotnet test TestCoveragePartialClasses.sln --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
folder cobertura.html - report converted from Cobertura.UnitTests.TestCoveragePartialClasses.results.xml
by ReportGenerator.exe with option -reporttypes:Html
folder opencover.html -report converted from OpenCover.UnitTests.TestCoveragePartialClasses.results.xml
by ReportGenerator.exe with option -reporttypes:Html
As you can see the Html
report converted from OpenCover.UnitTests.TestCoveragePartialClasses.results.xml
contains valid coverage
While the Html
report converted from Cobertura.UnitTests.TestCoveragePartialClasses.results.xml
contains merged coverage(which is invalid):
Thanks for providing a minimal sample. Now I have understood the problem.
It's already fixed. A new release (4.3.6) should be available within the next 30 minutes.
There is issue when we convert
Cobertura
XML toHTML
When we generate report for partial classes Generator merges all coverage to the first part of partial classes.