On other builds I see the following, which is what I want.
The Desired Outcome
This working build uses VSTest
The build I am trying to get code coverage working on is using Npm@1
'run test-with-coverage'
to generate coverage, and PublishCodeCoverageResults@2
to publish with summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'
.
I see the code coverage tab with correct coverage data, but on the summary screen I just see “Get started” Undesired Outcome
I’ve search google and bing, and talked through it with copilot. I upgraded the pipeline from PublishCodeCoverageResults@1, to PublishCodeCoverageResults@2.
I can reproduce the same on my side. The task PublishCodeCoverageResults@2
is used to publish code coverage result not test result.
You can add PublishTestResults@2 task to publish the test result.
Make sure you have test result(TEST-RESULTS.xml) generated at the Npm@1
run test-with-coverage
task.
For example, my package.json for npm test
task:
{
"name": "HelloWorld",
"private": true,
"version": "0.0.0",
"description": "Hello World",
"main": "server.js",
"author": {
"name": "",
"email": ""
},
...
"scripts": {
"test": "nyc --reporter=cobertura --reporter=html ./node_modules/.bin/mocha tests/**/*.js --reporter mocha-junit-reporter --reporter-options mochaFile=./TEST-RESULTS.xml"
}
}
The yaml sample:
- task: Npm@1
displayName: 'npm test'
inputs:
command: custom
customCommand: 'test'
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/TEST-RESULTS.xml'
testRunTitle: 'Test results for JavaScript'
- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
0