Dotcover coverage with multiple runners

Must-share information (formatted with Markdown):

  • SonarQube Developer Edition 9.6.1
    sonar-scanner-msbuild-5.5.3.43281-net5.0\SonarScanner.MSBuild.dll

Dear community,

We are running a pipeline at gitlab for a NET framework project. We use 3 different runners with 3 executors each, they can pick any job. Some test jobs can be run in parallel.

  • Build: Compile and Archive as artifacts result of compilation as pdb’s, dll’s… for later reuse at test jobs
  • Test (Unit x 7, Component x 3, Integration, System): Using dotcover command line with Nunit test runner creating dcvr coverage file for each test project
  • Sonar: Merge dcvr files coming from different test jobs and generate html coverage report, invoke sonar begin, re-compile, invoke sonar end

Our finding is that coverage is only properly gathered by Sonar when it uses the same working directory and runner that was used at build stage, otherwise it will show no coverage.

Is there anyway to overcome this limitation?

Thanks in advance.

Hello

This is mentioned in the code coverage guide under the “Not running all commands from the same folder” section.

You can read there the explanation. Running commands from the same folder is the only scenario we currently support.

To better understand your need: what is your use case, why do you consider this to be a limitation?

Hi Andrei,

Thanks for your answer.

Our use case:

We are running a pipeline at gitlab for a NET framework project. We use 3 different runners with 3 executors each, they can pick any job. Some test jobs can be run in parallel.

  • Build: Compile and Archive as artifacts result of compilation as pdb’s, dll’s… for later reuse at test jobs
  • Test (Unit x 7, Component x 3, Integration, System): Using dotcover command line with Nunit test runner creating dcvr coverage file for each test project
  • Sonar: Merge dcvr files coming from different test jobs and generate html coverage report, invoke sonar begin, re-compile, invoke sonar end

Find it as a limitation as sonar job would need to be run not only by the same runner but also executor that executed build stage for that given pipeline which is not straightforward at gitlab and prone to become a bottleneck when several pipelines run in parallel.

Hello

You can run the code coverage from different agents, as long as the paths inside the code coverage reports are all relative to the scan working directory.

Have a look at our sonar-dotnet pipeline.

We run code coverage for two different target frameworks (line 158), upload the coverage reports (line 185), and then during the analysis step (line 208) we download the coverage reports (line 281) and use them in the Sonar analysis.