Skip to content

Feature Request: New dotnet tool command for merging results in standalone mode #1015

Open
@chaoticsoftware

Description

@chaoticsoftware

N.B. Alert! :)
I just started looking into adopting coverlet for our code coverage purpose. We run tests across many different modules not only with parallelism within the test job, but also across several different jobs running in parallel in our pipeline. Having to run tests in serial would be a huge (and unacceptable) blow back to our pipeline latency. Aside from that, I've noticed from several threads in here that MergeWith has its issues right now, even when executing tests in parallel. So I have a feature request, that should be fairly easy to implement. In fact, I just prototyped it for myself:

Why not have a dotnet tool command for merging existing json reports into a single final report. That way one can still do a massively parallel testing, and just run the command to merge all the results together. That command seems to be performing well even if results are merged in a single thread, but ultimately if needed, can be further enhanced to work in a multi-threaded mode using concurrent dictionaries and what not to replace the existing single-threaded data structures that are used for representing the results.

So, the pipeline would look like this (an approximation of the actual syntax just to convey the point):

- job: Build
  steps:
     - dotnet build test.sln
- job: Test
  dependsOn: Build
  strategy:
    - parallel: n
  steps:
    - dotnet test test.sln --no-build --collect:"XPlat Code Coverage" -s ./test.runsettings
    - Copy ./**/coverage.json to $(build.artifactStagingDirectory)/cc
       Flatten: true
    - publish $(build.artifactStagingDirectory)/cc
      artifact: CC_$(System.JobPositionInPhase)
- job: CodeCoverage
  dependsOn: Test
  steps:
    - download
       patterns: 'CC_*'
       path: $(pipeline.workspace)/coverageResults
    - dotnet merge-coverage-reports $(pipeline.workspace)/coverageResults/**/coverage.json -o $(pipeline.workspace)/coverageResults/merged -f json,cobertura
    - publishCodeCoverage: $(pipeline.workspace)/coverageResults/merged

Does this sound reasonable?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions