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

不问归期 提交于 2019-11-29 17:51:35

问题


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.


回答1:


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.




回答2:


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

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