从Postman测试生成Sonar代码覆盖率报告 [英] Generate Sonar code coverage report from Postman tests

查看:480
本文介绍了从Postman测试生成Sonar代码覆盖率报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否有可能(以及如何)从Postman集成测试执行中生成代码覆盖率?

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

我们有基于Postman的集成测试,我们通过Windows shell命令在Jenkins上执行它们. 令人沮丧的是,我们不知道如何生成代码覆盖率报告并将其发布到SonarQube.

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.

非常感谢您!

推荐答案

您可以在localhost环境中运行测试,这种方式的覆盖率将照常进行测量.实际上,这是一个很好的CI实践,因为您将测试要部署的代码,而不是先前发布的版本.

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.

要实施该解决方案,您应该将测试URL指向localhost(为方便主机在本地或生产环境之间切换,最好使用环境变量指示主机),然后在jenkins项目中添加执行前和执行后为了在执行之前启动本地服务器,然后在执行之后停止它.

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)

这篇关于从Postman测试生成Sonar代码覆盖率报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆