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!
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)
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