Generate Sonar code coverage report from Postman tests

风格不统一 提交于 2019-12-07 10:13:06

问题


Does anyone know if it is possible(and how) to generate code coverage out of the Postman integration tests execution?

We have integration tests based on Postman and we execute them on Jenkins via a Windows shell command. What is quite frustrating, that we don't know how to generate code coverage report and publish it into SonarQube.

Thank you very much in advance!


回答1:


You can run the tests in the localhost environment and this way coverage will be measured as usual. Actually this is a good CI practice since you'll be testing the code you're trying to deploy rather than a previously published version.

To implement the solution you should point the tests URL to localhost (it's a good idea to indicate the host using a environment variable in order to easily switch between local or production environments) and then add pre and post executions in the jenkins project in order to start the local server before execution and stop it afterwards.

This link shows how to implement the solution on node, and this other link shows how to stop the local server after execution)




回答2:


At present, no such functionality is provided within Newman, as mapping test coverage via an external command is not standardised across various stacks. Making something like this available (and usable) would also involve creating and providing a manifest of all application URL endpoints to Newman (and altering Newman to interpret it as well), so that there is a global namespace to check percentage coverage against.

Please see https://github.com/postmanlabs/newman/issues/408 for more details.



来源:https://stackoverflow.com/questions/39835992/generate-sonar-code-coverage-report-from-postman-tests

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