I would like to share my approach to know the coverage of our functional o automate testing, that would be very usefull when we're near of the release date or to know the real impact of our test during the each sprint.
A. Steps before deploy the build in to QA enviroment 1. Create a pom with or just add the following plugin to our pom http://pastebin.com/U60GH0Ht 2. Then execute mvn clean compile mvn jacoco:prepare-agent mvn jacoco:instrument -Dincludes=* # The instrumented .classes files are located in /target folder mkdir target2 xcopy target target2 /s /e # these 2 steps are going to be detailed later. B. Then deploy the build in qa enviroment. 1. java -classpath C:\Users\myuser\.m2\repository\org\jacoco\org.jacoco.agent\0.6.4.201312101107\org.jacoco.agent-0.6.4.201312101107-runtime.jar;target\classes com.ts.main.Main # Please be aware that I loaded in to the classpath the jacoco agent jar and my project target folder # Now you can start with functional testing or execute your scripts. At the end of the day close your application and a jacoco.exec file is going to be generated. C. To see the coverage report executes the following lines mv jacoco.exec target/jacoco.exec mvn jacoco:restore-instrumented-classes mvn jacoco:report # jacoco is going to restore the .class files in target directory, with no instrumented classes, thats why a copy of target folder was created earlier. # A folder "site" is created with a complete report of your current coverage. D. If the next day you would like to continue your testing just adding the new coverage achieved without lose the coverage of days before 1. mv target/jacoco.exec target/jacoco1.exec 2. java -classpath C:\Users\myuser\.m2\repository\org\jacoco\org.jacoco.agent\0.6.4.201312101107\org.jacoco.agent-0.6.4.201312101107-runtime.jar;target2\classes com.ts.main.Main #Continue your testing. Be aware that jacoco.exec file was saved with a different name and the target2 folder with instrumented classes is loaded to the java class path. 1. Now when the app is closed a new jacoco.exec file is created. 2. mv jacoco.exec target/jacoco2.exec Finally use this example http://www.eclemma.org/jacoco/trunk/doc/examples/java/ReportGenerator.java to merge jacoco1.exec, jacoco2.exec files and get the current coverage report. -- You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
