Jacoco远程机器的代码覆盖率 [英] Jacoco code coverage for remote machine

查看:88
本文介绍了Jacoco远程机器的代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到这个答案,但几乎找不到它.我正在进行API测试,在执行过程中,我需要从本地计算机上调用其余的API.本地计算机包含maven项目和一个调用各自的rest API的框架.

I tried to find this answer but hardly found it anywhere. I am doing the API testing, In process I need to call the rest API from my local machine. local machine contains the maven project and a framework to call respective rest API.

我需要检查远程Rest API的代码覆盖率,并根据代码覆盖率形成一份报告.请帮忙,该怎么做?

I need to check the code coverage of remote Rest API and form a report based on the code coverage. please help, how to do that?

注意:我发现此链接很有用,但未明确说明该怎么做?

Note: I found this link useful but it does not elaborate clearly on what to do?

http://eclemma.org/jacoco/trunk/doc/agent.html

推荐答案

您可能会进行一些文件复制-取决于运行测试的方式.

you will probably do a bit of file copying around - depending on the way you run the tests.

JaCoCo作为Java代理运行.因此,通常您会像链接到应用程序服务器的启动脚本的文档中所提到的那样添加javaagent参数.

JaCoCo runs as a java agent. So you usually add the javaagent parameter as mentioned in the docs you linked to the start script of you application server.

-javaagent:[yourpath/]jacocoagent.jar=[option1]=[value1],[option2]=[value2]

因此它看起来像:

java -javaagent: -jar myjar.jar

使用tomcat可以将"-javaagent"部分添加到JAVA_OPTS或CATALINA_OPTS环境变量中.对于其他服务器应该相似.

Using tomcat you can add the "-javaagent" part into JAVA_OPTS or CATALINA_OPTS environment variables. Should be similar for other servers.

这将创建jacoco * .exec文件.您需要将它们复制回构建服务器或CI服务器以显示其结果(例如,如果您使用声纳,则在运行声纳报告器之前​​需要这些文件).重要的是只包含您感兴趣的软件包.

this will create the jacoco*.exec files. you need to copy those back to your build or CI server to show its results (for ex if you use sonar you need those files before running the sonar reporter). Its important to just include the packages you're interested in.

您还可以为每个测试版本创建一个jacoco.exec文件(用于单元测试的jacoco.exec,用于集成测试的jacoco-it.exec,用于应用程序测试的jacoco-at.exec).

You can also create one jacoco.exec file per test flavour (jacoco.exec for unit tests, jacoco-it.exec for integration tests, jacoco-at.exec for application tests).

我不会将覆盖范围与性能测试相结合-还要提一下.

And I would not mix coverage with performance testing - just to mention that too.

在stackoverflow上有一些

There are some examples on stackoverflow for JBoss

这篇关于Jacoco远程机器的代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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