Retrieving number of tests covering a statement with JaCoCo

146 views
Skip to first unread message

Ali Parsai

unread,
Jul 25, 2016, 8:31:21 AM7/25/16
to JaCoCo and EclEmma Users
Hello everyone, 

I'm trying to integrate JaCoCo in my research project, and I need to find out how many tests cover a certain statement. The closest I got to this information from Cobertura and Clover was number of times the statement is executed, but that is quite different from what I want. Can you show me the direction I need to take to implement this into JaCoCo, or tell me whether it is possible to create this feature in JaCoCo without huge development effort?  

Thanks in advance!

Evgeny Mandrikov

unread,
Jul 28, 2016, 12:28:11 PM7/28/16
to JaCoCo and EclEmma Users
Hi,

JaCoCo does not provide coverage per test out of the box, but using JaCoCo APIs it is definitely possible to get this data without any modifications in JaCoCo codebase.
Some time ago I did a prototype, which end up being presented in SonarQube:
It works by requesting JaCoCo APIs to start a new coverage session each time new test starts, which means:
  • you need to know test boundaries, which creates dependency with a testing framework ( SonarQube provides listeners for JUnit and TestNG ) and that's mainly why this code is not presented in JaCoCo
  • you can guarantee that within one JVM tests won't be executed in parallel, still you can run tests in parallel using multiple JVMs
  • we did an improvement in JaCoCo recently ( https://github.com/jacoco/jacoco/pull/387 ) for this case, but anyway output might be significantly bigger than usual
Hope this helps and good luck with your research.

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