coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.98k stars 386 forks source link

Hiding and excluding some parameters on the Coverage Code tab (Azure DevOps) #1558

Closed olegsidokhmetov closed 2 weeks ago

olegsidokhmetov commented 10 months ago

Hello!

I have a question. Is it possible to hide "Risk Hotspots" in the "Coverage Code" tab (Azure DevOps pipelines)

aVsz3Sxkn3

and also exclude "Converge.Libraries.NuGetUtilities" and "nameWebApi" from the test results in the "Coverage Code" tab?

BpeBrhn8sy chrome_WhXDM8VEQa

May it possible from step unit test in Arguments after parameters `--logger:"console;verbosity=normal" --configuration $(buildConfiguration) --collect:"XPlat Code Coverage /p:Exclude="[nameWebApi.], [NuGet.]"

chrome_R6NENmEMZZ
daveMueller commented 10 months ago

Coverlet is only calculating the coverage report. For visualization it seems you are using reportgenerator. The whole html representation including the Risk Hotspots tab is created by reportgenerator and I don't know if this html report can be customized. Most likely not. But at least you should be able to exclude "Converge.Libraries.NuGetUtilities" and "nameWebApi" from the coverage report. I see you are using the collector version of coverlet because of --collect:"XPlat Code Coverage" and you try to filter with the msbuild-coverlet parameters (/p:Exclude=...). This will not work. If you are using the collector you need to define a runnsettings file with the filter which is described here: vstest-docs. If you are using the msbuild version of coverlet you can use the filter as described here: msbuild-docs

Bertk commented 10 months ago

Report Generator supports filters which can be used to remove unwanted content from HTML output. There is also a configuration tool available which covers all options.

The coverage results for the test projects are accumulated and the filters are applied before the Cobertura.xml file is created. Maybe you can use a summary report which does not have "Risk Hotspots".

   Report types:       The output formats and scope (separated by semicolon).
                       Values: Badges, Clover, Cobertura, CsvSummary, 
                       MarkdownSummary, MarkdownSummaryGithub, MarkdownDeltaSummary
                       OpenCover
                       Html, Html_Light, Html_Dark, Html_BlueRed
                       HtmlChart, HtmlInline, HtmlSummary, Html_BlueRed_Summary
                       HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Light, HtmlInline_AzurePipelines_Dark
                       JsonSummary, Latex, LatexSummary, lcov, MHtml, SvgChart, SonarQube, TeamCitySummary
                       TextSummary, TextDeltaSummary
                       Xml, XmlSummary

Maybe you can increase the threshold for the metric (see https://github.com/danielpalme/ReportGenerator/wiki/Settings)

image

We use it for the coverage report for coverlet CI builds.

https://github.com/coverlet-coverage/coverlet/blob/21d3964f0399a8b353894806f774fdcf973b4324/eng/build.yml#L39C1-L43C158

https://github.com/coverlet-coverage/coverlet/blob/21d3964f0399a8b353894806f774fdcf973b4324/eng/publish-coverage-results.yml#L12C1-L33C52

github-actions[bot] commented 6 months ago

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

danielpalme commented 4 months ago

Risk hotspots can be disabled. The assemblies can be excluded from the report.

Apply the following two settings (last two lines are relevant):

- task: reportgenerator@5
  displayName: ReportGenerator
  inputs:
    assemblyfilters: '-Converge.Libraries.NuGetUtilities;-*WebApi' 
    customSettings: 'settings:disableRiskHotspots=true'