coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.93k stars 385 forks source link

[BUG] coverlet does not support multiple report formats using CoverletOutput parameter #1610

Open Bertk opened 4 months ago

Bertk commented 4 months ago

Describe the bug coverlet.msbuild.tasks overrides code coverage result file using file name of given CoverletOutput parameter.

To Reproduce

execute command: dotnet test test\coverlet.core.tests\coverlet.core.tests.csproj --configuration debug /p:CollectCoverage=true /p:CoverletOutputFormat="json%2copencover" /p:CoverletOutput="C:\GitHub\coverlet\artifacts\Reports\coverlet.core\coverage.json" /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.xunit.extensions]*%2c[coverlet.tests.projectsample]*%2c[testgen_]*" --results-directory:"C:\GitHub\coverlet\artifacts\Reports\coverlet.core" --diag:"C:\GitHub\coverlet\artifacts\log\debug\coverlet.core.test.diag.log;tracelevel=diag"

Expected behavior 2 code coverage result files are available (formats: json, opencover)

Actual behavior Only one code coverage result file is available.

image

Configuration (please complete the following information): Please provide more information on your .NET configuration:

Additional context none

Bertk commented 4 months ago

fix CoverletOutput folder location #1601

Bertk commented 4 months ago

Filename for multiple report formats is currently not supported. CoverletOutput parameter without file shall be used instead e.g. /p:CoverletOutput="C:/GitHub/coverlet/artifacts/Reports/coverlet.core/"

image
daveMueller commented 4 months ago

I've seen that we have the same issue for coverlet.console. The idea to just use the output directory in those cases sounds good to me. We can also create a new issue for this.

grafik

Bertk commented 4 months ago

Update of GlobalTool.md should be sufficient e.g.

whenever more than one coverage format is used in combination with output parameter only a folder shall be used

current paragraph

The above command will write the results to the supplied path, if no file extension is specified it'll use the standard extension of the selected output format. To specify a directory instead, simply append a / to the end of the value.

coverlet <ASSEMBLY> --target <TARGET> --targetargs <TARGETARGS> --output "/custom/directory/" -f json -f lcov

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 3 months with no activity.