Jacoco Test coverage report shows 0%

前端 未结 1 726
渐次进展
渐次进展 2021-01-22 15:14

I have to get the code coverage of a application while business test are executed from a different code base.

I use: Maven as my build Jbehave as my testing framework. T

相关标签:
1条回答
  • 2021-01-22 16:13

    I was able to resolve this as follows

    1. Copy the application classes in to a instrumentation folder.

    2. Start the app server (tomcat in mycase) with Java arguments

      -javaagent:$WORKSPACE/target/lib/jacoco-agent-0.6.3.2.jar=includes=*,destfile=$‌​TOMCAT_HOME/jacoco-coverage.exec,append=false
      

      (I had the jacoco-agent jar copied in to my project at the layout)

    3. Execute the tests (this can be automated or manual)

    4. Stop the tomcat server (jacoco-coverage.exec is updated at this point)

    5. Execute ant report target. pointing the updated jacoco-coverage.exec and copied application class folder.

    Reference: http://car-online.fr/en/blog/fabien_duchene/2013-05-03-Java%20Code%20Coverage%20in%20Tomcat%20JSP%20applications,%20e.g.,%20WebGoat%20with%20Jacoco/

    Thanks @jens-schauder for pointing me to post this as the answer.

    0 讨论(0)
提交回复
热议问题