Search code examples
javascripttfscoberturaistanbulmonorepo

Publishing multiple cobertura coverages with TFS CI


I have a monorepo project, created with lerna. And, I use Karma+Jasmine for the unit testing. The project structure looks as follows:

|-packages
| |-package1
| | |-coverage
| | | |-cobertura
| | | | |-coverage.xml  // here goes the coverage report in cobertura format
| | | |-Browser1
| | | | |-html          // here goes the reports in html (istanbul) for Browser 1
| | | |-Browser2
| | |   |-html          // here goes the reports in html (istanbul) for Browser 2
| | |-src
| | |-tests
| |-package2
| | |-coverage
| | | |-cobertura
| | | | |-coverage.xml
| | | |-Browser1
| | | | |-html        
| | | |-Browser2
| | |   |-html        
| | |-src
| | |-tests
| .
| .
| .
|-karma.conf.js

The test setup is working properly and generating the html reports as well as the coverage.xml in Cobertura format inside the each individual package. In TFS CI, I have a "Publish Code Coverage Results" build step to publish the coverage results with following values for different options:

  • Code Coverage Tool: Cobertura
  • Summary File: $(System.DefaultWorkingDirectory)\packages\*\coverage\cobertura\coverage.xml
  • Report Directory: $(System.DefaultWorkingDirectory)\packages\*\coverage (for HTML reports)

However, the build step warns about following

Multiple file or directory matches were found. Using the first match: C:\MyAgent\path\to\packages\package1\coverage\cobertura\coverage.xml

Multiple file or directory matches were found. Using the first match: C:\MyAgent\path\to\packages\package1\coverage

Naturally it also shows the coverage results for only one package. Is there any way to publish all coverage reports without adding a build step in CI for each package?


Solution

  • Seems you are using the Publish Code Coverage Results task, it's unlike to use Publish test results task. You could not be able to publish multiple coverage test results in a single task.

    The Arguments of this task is Summary File not like Test results files of Publish Test Results

    There are two coverage.xml file in your file structure. So it will only use the first match just as message mentioned. Source code of the task for your reference.

    You have to add another Publish Code Coverage Results task in build pipeline for each package.