Tuesday, May 23, 2017

How to mesure code coverage on tomcat using jacoco and eclipse

Step by step


1) Install EclEmma plugin to eclipse (that actually uses jacoco engine)
 
2) Find jacocoagent.jar in eclipse installation (Me copied it to separate directory c:\java\jacoco-eclipse-jee-mars-1-win32-x86_64\ just for conveninence )
 
3) Apply following changes to your tomcat launch configuration
3.a) Open launch configuration (green rectangle)
 
3.b) Add  -javaagent:C:/java/jacoco-eclipse-jee-mars-1-win32-x86_64/jacocoagent.jar=output=tcpserver as it shown on screen below
 
3.c) Launch server with your application

4) Configure your coverage view
4.a) Window>Show View> Java/ Coverage
 
4.b) Do right click on a view and select "Import session"
 
4.c)Select "Coverage Session"
 
4.d) select default settings for coverage session as it shown above
 
4.e) and select source folders you like to gather information from
 
4.f) data is not updated at runtime, use right click and "Refresh" on view (again green rectangle)
 

No comments:

Post a Comment