JaCoCo creates an empty file at startup to ensure that location is writable. And all the information is written at the JMV shutdown using https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread) I doubt that termination of Tomcat by Ctrl-C results in graceful JVM termination, and thus doubt that hook is executed. So please make sure that you gracefully terminate JVM.
On Wednesday, October 26, 2016 at 4:28:04 AM UTC+2, FEI YANG wrote: > > I'm new to use Jacoco to get restapi testing codecoverage of my java > webapp project. > The way I run my webapp project: > 1) use gradle to add embedded tomcat dependencies > 2) create a Main function to run tomcat(version8.5) like this: > https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat#deploy-to-heroku > 3) use gradle to create a jar file > 4) java -jar xxx.jar in other place(wanna to deploy to aws) > now after run jar file, tomcat start runing and api response is ok > > I also wrote sample test code using rest-assure > in this situation how could I use jacoco to coverage code when running the > jar file? > > I tried add -javaagent like this: > java -javaagent:jacocoagent.jar=classdumpdir=dump -jar xxx.jar > > when I stopped run using ctrl-c, java class files dumped into dump > folder and* a jacoco.exec file created but 0 bytes*... > > please help me.. > お願いします。 > 帮帮忙。。 > > -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/5cd31e25-103b-4770-b97f-489c5f20de1e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
