codacy / docs

Codacy documentation
https://docs.codacy.com
Other
21 stars 40 forks source link

[DOCS-350] Add instructions on how to generate coverage reports using xUnit #1020

Closed prcr closed 2 years ago

prcr commented 2 years ago

Type of feedback

Feedback

It's possible to generate a coverage report using xUnit, and we can include this information in the documentation on how to generate coverage reports:

Our team checked and it seems that you can make XUnit emit a opencover report, which we support.

By default, running dotnet test does not save the test results to a file, so in order to generate a report in a supported format you can install Coverlet:

dotnet add package coverlet.collector

Then set up the “test” task in the Tests project:

{ "label": "test", "command": "dotnet", "args": [ "test", "/p:CollectCoverage=true", "/p:CoverletOutputFormat=opencover" ], "problemMatcher": "$msCompile" }

Now running dotnet test will save the output to a file named “coverage.opencover.xml”, which can be uploaded to Codacy.

Affected pages This feedback applies to the following documentation pages / URLs:

https://docs.codacy.com/coverage-reporter/#generating-coverage

Additional context If applicable, provide any other context or information that could be useful in updating the documentation:

github-actions[bot] commented 2 years ago

Internal Jira issue: DOCS-350

prcr commented 2 years ago

I propose that, for now, we only include Coverlet as a code coverage tool that is able to generate report files in a format that Codacy Coverage Reporter can understand.

I would say that including a list of "supported" test frameworks such as xUnit is out of scope since the Codacy Coverage Reporter only cares about the output format of the test reports and not the process for creating those reports.

prcr commented 2 years ago

The following documentation page now mentions Coverlet as a possible way of generating test coverage data in a format that is supported by Codacy:

https://docs.codacy.com/coverage-reporter/#generating-coverage