I'm currently trying to generate code coverage reports for manual tests in a Maven project. I'm using Netbeans with the JaCoCO plugin.
The reports are properly generated when I run my unit tests.
What I need:
1. Run the program
2. Click some buttons in the program
3. Exit the program
4. Get a code coverage report for that run
After installing the JaCoCo plugin, the agent was already initialized for each run.
I figured that I could just add the goal "jacoco:report" after "exec" to get a report for non-test runs, but that did not work. No report is generated, although "jacoco:report" is clearly running.
I guess the problem is my insufficient understanding of Maven and the JaCoCO agent. If someone could help me with this, I'd be glad.
This is my configuration and the log of an example run:
From my pom.xml:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.5.7.201204190339</version>
<configuration>
<excludes>
<exclude>**/view/**</exclude>
<exclude>**/exceptions/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
From my nbactions.xml:
<action>
<actionName>CUSTOM-Run project and collect code coverage</actionName>
<displayName>Run project and collect code coverage</displayName>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
<goal>jacoco:report</goal>
</goals>
<properties>
<exec.args>-classpath %classpath edu.kit.project.controller.MainController</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
Example run:
cd /Users/paddya/Documents/project; JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home "/Applications/NetBeans/NetBeans 7.3.app/Contents/Resources/NetBeans/java/maven/bin/mvn" "-Dexec.args=-classpath %classpath edu.kit.project.controller.MainController" -Dexec.executable=/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java --errors -e process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec jacoco:report
Error stacktraces are turned on.
Scanning for projects...
------------------------------------------------------------------------
Building Project
------------------------------------------------------------------------
[jacoco:prepare-agent]
argLine set to -javaagent:/Users/paddya/.m2/repository/org/jacoco/org.jacoco.agent/0.5.7.201204190339/org.jacoco.agent-0.5.7.201204190339-runtime.jar=destfile=/Users/paddya/Documents/project/target/jacoco.exec,excludes=**/view/**:**/exceptions/**
[resources:resources]
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 2 resources
[compiler:compile]
Nothing to compile - all classes are up to date
[exec:exec]
Exiting....
[jacoco:report]
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 12.693s
Finished at: Tue Aug 20 13:41:02 CEST 2013
Final Memory: 10M/24M
------------------------------------------------------------------------
Thanks in advance for your effort!
Patrick Bisenius