Code coverage exclude: local OK, Azure DevOps => not OK
See original GitHub issueHi,
I am writing a .NET Core 3.1 web api and have a unit test project to run my unit test. Everything is being done in Visual Studio Professional 2019 (latest update).
In my unit test project (xUnit) I have following references to have coverlet working
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.6.1" />
When I run locally, my excludes do work (I want to exclude everything with Models in the namespace)
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=./MyCoverage/ /p:Exclude="[*]*.Models*"
Now, when I include it in my build pipeline, with following step (and of course a step publishing it as well)
- task: DotNetCoreCLI@2
displayName: Run unit tests
inputs:
command: test
projects: '**/*Test/*.csproj'
arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=./MyCoverage/ /p:Exclude="[*]*.Models*"'
publishTestResults: true
The coverage is calculated, report is available, but…
As you may see, it keeps the coverage on model in the report. Since the commands are the same, I am running out of ideas what the issue is here to be honest 😃 It’s not like I can debug locally, as it works over there 😃
UPDATE: Maybe good to know, the log in the build pipeline reports Whereas the report itself display for the API.Data project 66.6% line coverage & 70% for branch coverage
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top GitHub Comments
@MarcoRossignoli Thanks a lot, it works!
Hi thanks for your quick reply I just did another test and now I noticed something weird
Locally, I am using reportgenerator version 4 something. Azure Devops is loading in a version 1.x 😕 Stupid Azure DevOps. I am manually adding ReportGenerator task now, that should do the trick