Getting code coverage of my application using JaCoCo Java agent on Tomcat

前端 未结 3 1378
星月不相逢
星月不相逢 2020-12-31 10:05

I want to measure the code coverage of integration tests using the JaCoCo and Sonar tools.

For that, I start my Tomcat 5.5 configured with the JaCoCo agent in order

3条回答
  •  青春惊慌失措
    2020-12-31 10:41

    I realize this may not have been an option 2 years ago when this question was asked, but presently you have some other options available to fetch the JaCoCo execution data without shutting down Tomcat (or any JVM instrumented with the JaCoCo java agent).

    First take a look at the current documentation for the JaCoCo Java Agent: http://www.eclemma.org/jacoco/trunk/doc/agent.html

    You can use the output=tcpserver option on the JaCoCo agent to have the Java agent listen for commands. You can set address=* to have the tcpserver listen on all interfaces, and you can set the port=6300 argument to choose the port where the tcpserver should listen.

    Through the tcpserver the JaCoCo java agent can be instructed to send you the data whenever you ask for it.

    If your JVM is currently exposing JMX you have another option which you can utilize without opening additional ports. By setting the jmx=true option the JaCoCo java agent exposes an MBean which you can interact with.

    If you are using maven you can take a look at the plugin I recently wrote in order to gather JaCoCo data from remote JVM's while running. The project for the plugin is located at:
    https://github.com/mattcj/jacocotogo

提交回复
热议问题