Jacoco code coverage for remote machine

雨燕双飞 提交于 2019-12-23 12:03:28

问题


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.

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


回答1:


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

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]

so it would look like:

java -javaagent: -jar myjar.jar

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

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.

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.

There are some examples on stackoverflow for JBoss



来源:https://stackoverflow.com/questions/33211983/jacoco-code-coverage-for-remote-machine

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