Include code coverage report in VSTS, Is Test Adapter mandatory for VSTS?

限于喜欢 提交于 2019-11-30 12:29:55
Krishh

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',
    ...
  }
}

karma-remap-coverage:

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!