coverlet-coverage / coverlet

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

How to generate report in .coverage format #1440

Closed qinl-li closed 1 year ago

qinl-li commented 1 year ago

Hi,

I am working on adding a coverage status check for our pull request. According to here, it only access .coverage file to make the check shows up.

Here is the command line we are using for running the test, but it only generated HTML format. I tried to pass different format value and still can't get .coverage file. Is there any limitation on Linux container?

- task: DotNetCoreCLI@2 displayName: 'Test' inputs: command: test publishTestResults: false # cannot publish test result due to policy restriction, disable it here and use PublishTestResults@2 to publish projects: 'src//*.Tests.csproj' arguments: '--no-restore --logger trx -c $(BuildConfiguration) /p:BuildMetadata=$(Build.BuildNumber) --settings $(Build.SourcesDirectory)/src/Tests.runsettings --filter "Category=Unit|Category=Integration" -m:1 --results-directory $(Build.SourcesDirectory)/src/unit-test/test-result/ /p:CollectCoverage=true /p:CoverletOutput=$(Build.SourcesDirectory)/src/unit-test/coverage-result/ /p:MergeWith=$(Build.SourcesDirectory)/src/unit-test/coverage-result/coverlet.json /p:CoverletOutputFormat="json%2ccobertura"**'

daveMueller commented 1 year ago

I think the link you posted refers to Visual Studio coverage. AFAIK coverlet doesn't have support for this format but I also could be wrong. Nevertheless you could try it with dotnet-coverage.

qinl-li commented 1 year ago

Thanks!

daveMueller commented 1 year ago

I'm closing this as it is a duplicate of #1445 and progress will be tracked there. Feel free to reopen.