coverlet-coverage / coverlet

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

Exclude not working on blazor project #1379

Open dazinator opened 2 years ago

dazinator commented 2 years ago

My xunit tests projejct references by backend asp.net core project, which hosts a front end blazor (wasm) project (and hence has a reference to it)

I am attempting to exclude this blazor project from code coverage.

The test is run via an azure devops yaml:

    - task: DotNetCoreCLI@2
      displayName: Test
      inputs:
        command: test
        projects: '**/*.Tests*.csproj'
        publishTestResults: true
        arguments: '--configuration $(BuildConfiguration) --no-build --collect "XPlat Code Coverage" /p:CoverletOutputFormat="cobertura%2copencover" /p:SkipAutoProps=true /p:Exclude="[Foo.Client]*"'

However after this runs, and I look at the report uploaded to devops, it still shows me types in the Foo.Client assemlby:

image

The exclude pattern appears correct to me, am I doing something wrong?

MarcoRossignoli commented 2 years ago

You should check with the diagnostics enabled https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/Troubleshooting.md#collectors-integration and look at what coverlet is filtering out.

Bertk commented 1 year ago

Please use .runsettings for your test see https://github.com/Bertk/coverlet/blob/master/Documentation/VSTestIntegration.md#advanced-options-supported-via-runsettings

or CLI parameter DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Exclude similar to https://github.com/Bertk/coverlet/blob/master/Documentation/VSTestIntegration.md#passing-runsettings-arguments-through-commandline

example: https://github.com/Bertk/arcade-light/blob/51084337e9b7ff744f86bf34ffa15098ae91a1a2/src/DotNetDev.ArcadeLight.Sdk/tools/XUnit/XUnit.Runner.targets#L67

github-actions[bot] commented 10 months ago

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

Bertk commented 2 weeks ago

Please verify whether the problem still exists using the latest coverlet 6.0.2 release.