I have two projects, one that shows the coverage and the other that shows 0.0%
The one that shows no test coverage is not in the root directory of the repository, it is one folder down.
ALM used: Azure DevOps
CI system used: Azure DevOps
Scanner command used when applicable: Prepare, Analyse and publish
Languages of the repository: C# .Net Core
Tried adding DebugType Ful, changing framework from 2.2 to 3.0, adding GUIDs to each project
Logs
This is the project that does not show the coverage
INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Parsing the Visual Studio coverage XML report d:\a\_temp\{some-guid-here}\VssAdministrator_fv-az23_2019-11-15.08_19_20.coveragexml
INFO: Adding this code coverage report to the cache for later reuse: d:\a\_temp\{some-guid-here}\VssAdministrator_fv-az23_2019-11-15.08_19_20.coveragexml
INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=281ms
This is the project that shows the coverage:
INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Parsing the Visual Studio coverage XML report d:\a\_temp\{some-guid-here}\VssAdministrator_fv-az23_2019-11-14.13_08_50.coveragexml
INFO: Adding this code coverage report to the cache for later reuse: d:\a\_temp\{some-guid-here}\VssAdministrator_fv-az23_2019-11-14.13_08_50.coveragexml
INFO: Coverage Report Statistics: 21 files, 14 main files, 14 main files with coverage, 7 test files, 0 project excluded files, 0 other language files.
INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=111ms
are you building the projects in different pipelines, or the same one? (I’m guessing different ones since the datestamps on the .coveragexml files are different).
are you using the same build agent for both builds?
are you building solution files, or the .csproj files?
does the Azure Pipeline build summary show the expected coverage for both projects? e.g.
e.g.
could you share the detailed build log output for the Analyse step and the .coverage files with us, for both projects? You can get a detailed build log by running the build with the Azure Pipeline variable sonar.debug=true, and you can share the files privately by sending a private message (click on my user photo and select Message). Thanks.
Hi Duncan,
Thank you for the reply, it set me in the right direction.
I got this fixed, the main problem was that dotnet test --collect "code coverage" was generating coverage report that contained just coverlet dll, no actual project dll.
I tried to get this working in many ways, I still don’t understand why it works in a different project with same nuget versions and style of tests. in the end gave up and decided to use do this myself:
dotnet test PathTo.Tests.csproj --logger "trx;LogFileName=testresults.trx" /p:CollectCoverage=true "/p:CoverletOutputFormat=\"cobertura,opencover\""
Cobertura output is needed for VSTO, because it does not support opencover: