Instruction coverage at method level instead of class level

63 views
Skip to first unread message

Benjamin Danglot

unread,
Jul 27, 2017, 8:37:02 AM7/27/17
to JaCoCo and EclEmma Users
Hello all,

I am using Jacoco inside a project, to compute instruction coverage of test methods.

For now, I could only count the instruction coverage at test class level. I would to know if it is possible to count the instruction coverage at test method level.

For instance, I have example.Example, which is testes by example.TestSuiteExample. The test class contains 2 test methods test1 and test2.

Thanks to the CoverageBuilder and the Analyzer, I'm able to measure the number of instructions covered by the class example.TestSuiteExample.

However, I would like to know the number of instruction covered by test1 and test2 independently. For now, I found a work around: I run Jacoco for each test method, one by one.

But this is costly in terms of time computation.

Would mind to indicate me if there is a way to log at the test method level instead of at the test class level?

If not, there is a way to implement it?

Best regards,

-- Benjamin DANGLOT.

Marc Hoffmann

unread,
Jul 27, 2017, 11:32:38 AM7/27/17
to jac...@googlegroups.com

Hi,

the Analyzer and CoverageBuilder works only on one ExecutionDataStore at time. If you want to calculate coverage separately for different test cases you need to capture execution data separately and do the analysis separately. For large test sets this will create enormous amount of data. Therefore such a feature was never integrated in JaCoCo.

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/5a09a058-be1f-478b-922b-242d1b385cf7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Benjamin Danglot

unread,
Jul 28, 2017, 6:59:03 AM7/28/17
to JaCoCo and EclEmma Users
Hi Marc,

Thank you for your answer.

There is a way to integrate this feature in JaCoCo?


Best regards,

-- Benjamin DANGLOT.

Evgeny Mandrikov

unread,
Jul 28, 2017, 10:03:37 AM7/28/17
to JaCoCo and EclEmma Users
So far there is no plans to integrate this in JaCoCo for many reasons, one of which as  Marc said - is amount of data.

However you can implement your own JUnitExecutionListener which will use public JaCoCo runtime API ( http://www.jacoco.org/jacoco/trunk/doc/api/index.html ) to record per-test data.

Please also do a search of messages in this group - such questions were asked and answered multiple times in past, e.g. https://groups.google.com/d/msg/jacoco/Qs9P5cyt58s/gzsBAP8qBgAJ

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