I have a remote application running on a JBoss server. I'm currently running tests which make REST calls to this service. Is it possible to generate coverage reports of code on the server side?
Regards
Leon
Thanks for the reply. On the remote server, I've had Jacoco added to my remote application and have a java agent running with this property: javaagent:%DELIVERABLE_HOME%/jacoco/lib/jacocoagent.jar=output=tcpserver,address=*,port=6300,append=true,includes=com.myproject.*
I have an Ant build with the following tasks:
<target name="clean">
<delete dir="${report.dir}" />
</target>
<target name="dump" depends="clean">
<jacoco:dump address="${server.address}" port="${server.port}" reset="true" destfile="${jacocoexec.dir}/${jacocoexec.filename}" dump="true" />
</target>
<target name="coverage_report" depends="dump">
<jacoco:report>
<executiondata>
<file file="${jacoco.exec.file}" />
</executiondata>
<structure name="JaCoCo Ant Coverage Reports">
<classfiles>
<fileset dir="${instrumented.classes.dir}" includes="**/*.class" />
</classfiles>
<!-- Jacoco Source Files -->
<sourcefiles encoding="UTF-8">
<fileset dir="./coverage_output/source_dir/projects/myprojects/src/main/java" />
<fileset dir="./coverage_output/source_dir/projects/myprojects2/src/main/java" />
</sourcefiles>
</structure>
<html destdir="${report.dir}" />
<csv destfile="${report.dir}/report.csv" />
<xml destfile="${report.dir}/report.xml" />
</jacoco:report>
</target>
At the same time, I have a Node server running in the same directory, with the server address pointing to my machine's IP address. When I tried running the report generation Ant task, the generated reports would be empty and the session data is empty as well. Am I doing anything wrong in this case?
Yes the session page is completely empty.
Yes, the variables are pointing to the right locations. For the original class files, I forgot to mention that I have the java agent running with "classdumpdir=%DELIVERABLE_HOME%/jacoco/class_dumps" on my remote server. I'm running a scp command to retrieve them from the server before running the Ant build, which is pointing to the folder containing the class files.
Here are the Ant logs:
clean:
dump:
[antlib:org.jacoco.ant] Could not load definitions from resource org/jacoco/ant/antlib.xml. It could not be found.
[jacoco:dump] Connecting to /10.238.83.64:6300
[jacoco:dump] Dumping execution data to /Users/lechin/Documents/git-paypal/Hackathon/code_coverage/coverage_output/jacoco/jacoco.exec
BUILD FAILED
/Users/lechin/Documents/git-paypal/Hackathon/code_coverage/build.xml:50: Unable to dump coverage data
at org.jacoco.ant.DumpTask.execute(DumpTask.java:156)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:854)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.io.DataInputStream.readByte(DataInputStream.java:265)
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:82)
at org.jacoco.ant.DumpTask.execute(DumpTask.java:151)
... 16 more
Regards
Leon
This is my current scenario. I've been running a test through a TestNG Eclipse plugin. Through the test case, it is hitting my JBoss application via a REST call. Upon termination of the test case, I am performing the Ant build.
Assuming that the target port is available and there are no firewall issues, is this how it supposed to run?
Apologies if it's confusing.
Regards
Leon
Thank you for your replies. I've been trying to get it work and finally found the problem with the report generation. I had to specify the specific address in the javaagent address parameter, which I pointed to the Unix server that my JBoss application was running on.
It was only after I had done that, was I able to obtain a report from running the ant build.
Thank you for your help!
Cheers