Why lost coverage?

193 views
Skip to first unread message

thin...@gmail.com

unread,
Oct 9, 2019, 4:57:39 AM10/9/19
to JaCoCo and EclEmma Users
1. I have one project (name: ProjectA) which includes some java file (for example: filenameX.java)
2. I use maven to build it to generage jar package
3. I use the follow command to start this server: 
        java -javaagent:/data/jacoco-0.8.4/lib/jacocoagent.jar=includes=*,output=tcpserver,port=2014,address=127.0.0.1 -jar target/ProjectA-1.0.0-SNAPSHOT.jar
4. I use curl to call the server, filenameX.java is called
5. I use `dump` to get jacoco.exec file
6. I use `report` to generate coverage:
       total coverage: 22%, filenameX.java coverage: 12%


Then, I update filenameX.java and re-build and re-start server,
I again use `dump` to get jacoco.exec file
I use `merge` to merge old and new exec file
I use `report` to generate coverage:
    total coverage: 8%, filenameX.java coverage: 0% <= Why???

why? and how should I fix it? thanks!

Marc Hoffmann

unread,
Oct 9, 2019, 5:26:10 AM10/9/19
to jac...@googlegroups.com

Hi,

you cannot merge different versions of a class file. Class files have to be the exact same at runtime and at report time.

If you generate the report the second time only coverage for the new version (which haven't been executed) is shown. When you open the "Sessions" link on the top right corner of the report you will probably see both versions of the filenameX class.

Documentation gives background information about class file identity in JaCoCo: https://www.jacoco.org/jacoco/trunk/doc/classids.html

Regards,

-marc

--
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 jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/2ece211c-459b-4d1d-916b-87d0cb8fd55e%40googlegroups.com.


thin...@gmail.com

unread,
Oct 9, 2019, 5:55:17 AM10/9/19
to JaCoCo and EclEmma Users
thanks a lot!
so the lost coverage I only can again run case to coverage it, right?

在 2019年10月9日星期三 UTC+8下午5:26:10,Marc R. Hoffmann写道:
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.

Marc Hoffmann

unread,
Oct 9, 2019, 7:36:53 AM10/9/19
to jac...@googlegroups.com
Correct. If you want to get coverage for the new version if the class you need to run your test again.

It is good practice anyways to re-run the tests when you change the code.



To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/3e5fb95c-6b94-4d5c-8924-69eb7109d448%40googlegroups.com.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages