I'm using JaCoCo to generate code coverage report and I have a number of scenarios to generate separate reports for. The problem is that the program is extremely huge and takes around 2 minuted to start and load all the class files.
I want to fetch the execution data on run time as soon as one of those scenarios is completed and then start with the next scenario, instead of restarting the server for each scenario.
Is there a way to do so?
All below is taken from official JaCoCo documentation at http://www.jacoco.org/jacoco/trunk/doc/
Java Agent described at http://www.jacoco.org/jacoco/trunk/doc/agent.html has option output
:
- file: At VM termination execution data is written to the file specified in the destfile attribute.
- tcpserver: The agent listens for incoming connections on the TCP port specified by the address and port attribute. Execution data is
written to this TCP connection.
- tcpclient: At startup the agent connects to the TCP port specified by the address and port attribute. Execution data is
written to this TCP connection.
and option jmx
:
If set to true the agent exposes functionality via JMX
exposed via JMX functionality as described in JavaDoc among others provides three following methods:
byte[] getExecutionData(boolean reset)
Returns current execution data.
void dump(boolean reset)
Triggers a dump of the current execution data through the configured output.
void reset()
Resets all coverage information.
Again from documentation there is also Ant Task dump
-
http://www.jacoco.org/jacoco/trunk/doc/ant.html:
This task allows to remotely collect execution data from another JVM without stopping it.
Remote dumps are usefull for long running Java processes like application servers.
dump
command in Command Line Interface -
http://www.jacoco.org/jacoco/trunk/doc/cli.html
dump
goal in jacoco-maven-plugin
- http://www.jacoco.org/jacoco/trunk/doc/dump-mojo.html
API usage examples include:
- MBeanClient.java This example connects to a coverage agent to collect
execution data over the JMX.
- ExecutionDataClient.java This example
connects to a coverage agent to collect execution data over the remote
protocol.
- ExecutionDataServer.java This example starts a socket server
to collect execution data from agents over the remote protocol.