vstest icon indicating copy to clipboard operation
vstest copied to clipboard

`dotnet-coverage merge` drops hit counts, sets them all to 1

Open AArnott opened this issue 2 years ago • 4 comments

Description

The merge command produces coverage data with hits="1" hard-coded for all covered lines.

Steps to reproduce

I have multiple cobertura coverage reports that I want to use dotnet-coverage merge to merge into one.

Consider these coverage files: TestResults.zip

dotnet-coverage merge TestResults\*xml -r -o merged.cobertura.xml -f cobertura

Expected behavior

I expect the merged report to reflect the hit counts for each line. In particular, the merged product should report that the {reporoot}\test\Library.Tests\Calculator.cs file's line 17 was hit 3 times.

I get the expected result when merging with the dotnet-reportgenerator-globaltool dotnet CLI tool.

Actual behavior

Every line reported in the merged .xml file reports hits="1".

merged outputs.zip contains outputs from both tools so you can compare.

AArnott avatar Sep 13 '22 19:09 AArnott

@AArnott our tooling supports only hits=1 or hits=0 for both collecting and merging. It is due to performance reasons.

jakubch1 avatar Sep 14 '22 06:09 jakubch1

Well, if this is by design, feel free to close. It seems odd that perf reasons come into play during a merge operation. And I'm surprised that tracking a bool is really that much faster than tracking and adding int, which ought to be roughly just as fast.

AArnott avatar Sep 15 '22 03:09 AArnott

We are considering adding possibility to collect number of hits. So let's keep this open and see if more people wants that. You are right that in case of merging this will not make it slower.

jakubch1 avatar Sep 15 '22 08:09 jakubch1

+1 to wanting counts. We use this today to help find "hotspots" where we have duplicate tests (or duplicative test setup) that we can should clean up.

MattKotsenas avatar Sep 23 '22 20:09 MattKotsenas