I am generating code coverage using Karma-coverage. I can host my output coverage folder on http-server and view it locally.
How do I make this report visible on VSTS code coverage tab?
Do I need to re-format my coverage result in VSTS compatible?
I have read about vsts-tasks, but I have no clue how to achieve the same.
Any help is appreciated.
VSTS Code coverage supports the outputted code coverage results in Jacoco or Cobertura formats. Karma-Coverage supports Cobertura format. Edit your karma.config.js for
karma-coverage:
coverageReporter: {
type : 'cobertura',
...
}
karma-remap-istanbul:
remapIstanbulReporter: {
reports: {
cobertura: './coverage/cobertura.xml',
...
}
}
remapCoverageReporter: {
cobertura: './coverage/cobertura.xml',
...
},
Once you configure the output format, you can use Publish Code Coverage task to upload code coverage data to VSTS.
With karma.conf.js file generated by angular CLI 1.2+, it is as simple as adding the cobertura report (instead of lcov report) in istanbul reporter :
coverageIstanbulReporter: {
reports: ['html', 'cobertura'],
fixWebpackSourcePaths: true
}
So when you will run your tests with the --code-coverage
option, a file named coverage-cobertura.xml will be generated in the coverage directory.
Then in your TFS/VSTS build, you can add a Publish Code Coverage task and specify the cobertura XML file.
来源:https://stackoverflow.com/questions/41314239/include-code-coverage-report-in-vsts-is-test-adapter-mandatory-for-vsts