Jacoco coverage lines count issue.

630 views
Skip to first unread message

yashwanth koundinya

unread,
Oct 6, 2016, 2:56:24 AM10/6/16
to JaCoCo and EclEmma Users
Hi Team,

Firstly thanks for the aggregate report feature which really helped me to generate report for the multi-module project.

Here I am facing 2 issues as below.

1. The coverage is 0% for all the tests which use PowerMock. I got your answer for the same from another post saying Jacoco doesn't work with framwork like PowerMock.

2. When I run the coverage using EclEmma in Eclipse I see the total lines count different (per each module and also the total sum) when compared to the total lines count found in the html report generated after the build. Why can this happen?

Please let me know for additional information.

Thanks
Yashwanth

Marc R. Hoffmann

unread,
Oct 6, 2016, 10:23:55 AM10/6/16
to jac...@googlegroups.com
Hi Yashwanth,

regarding your questions

1) Yes, this is a known limitation. As a work around for such scenarios we offer offline istrumentation (http://www.eclemma.org/jacoco/trunk/doc/offline.html).

2) This most likely happens because you use different compilers (ECJ vs. javac). JaCoCo relys on the debug information created by the compiler. Both compilers assign different lines to the compiled code: For example javac assigns the complete code of a multi-line expression to the first line of that expression, while ECJ assigns the different parts of the expression to the corresponding lines (so more lines in ECJ).

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/73b89dc2-eaec-47ec-bc91-a6682fad641d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hoffmann

Evgeny Mandrikov

unread,
Oct 6, 2016, 11:37:48 AM10/6/16
to JaCoCo and EclEmma Users
Just additional 2 cents: if my memory correct, then there were some changes in JDK 8 with introduction of lambda expressions about the way javac assigns lines to expressions.


On Thursday, October 6, 2016 at 4:23:55 PM UTC+2, Marc R. Hoffmann wrote:
Hi Yashwanth,

regarding your questions

1) Yes, this is a known limitation. As a work around for such scenarios we offer offline istrumentation (http://www.eclemma.org/jacoco/trunk/doc/offline.html).

2) This most likely happens because you use different compilers (ECJ vs. javac). JaCoCo relys on the debug information created by the compiler. Both compilers assign different lines to the compiled code: For example javac assigns the complete code of a multi-line expression to the first line of that expression, while ECJ assigns the different parts of the expression to the corresponding lines (so more lines in ECJ).

Regards,
-marc

On 06.10.16 08:56, yashwanth koundinya wrote:
Hi Team,

Firstly thanks for the aggregate report feature which really helped me to generate report for the multi-module project.

Here I am facing 2 issues as below.

1. The coverage is 0% for all the tests which use PowerMock. I got your answer for the same from another post saying Jacoco doesn't work with framwork like PowerMock.

2. When I run the coverage using EclEmma in Eclipse I see the total lines count different (per each module and also the total sum) when compared to the total lines count found in the html report generated after the build. Why can this happen?

Please let me know for additional information.

Thanks
Yashwanth
--
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+unsubscribe@googlegroups.com.
Hoffmann

yashwanth koundinya

unread,
Oct 7, 2016, 4:46:32 AM10/7/16
to JaCoCo and EclEmma Users
Hi Marc,

Thanks a lot for the details provided.

Being a beginner in coding I am not much aware of offline instrumentation. 

Can you please excuse me on that and provide an example on how offline instrumentation can be configured.

Thanks
Yashwanth 

yashwanth koundinya

unread,
Oct 7, 2016, 4:48:09 AM10/7/16
to JaCoCo and EclEmma Users
Adding to that I am using Maven 3.0.4 and a java web-app with multiple modules.

yashwanth koundinya

unread,
Oct 7, 2016, 4:57:29 AM10/7/16
to JaCoCo and EclEmma Users
Hi Marc,

One more question here. Does using offline instrumentation provide the coverage in combination for both PowerMockito and other tests or provides coverage for only PowerMocktio classes?

Thanks
Yashwanth 

Marc R. Hoffmann

unread,
Oct 7, 2016, 6:55:43 AM10/7/16
to jac...@googlegroups.com
Hi Yashwanth,

offline instrumentation is actually quite tricky and not recommended. But if you want to try there it's all documented and there is also Maven example:

http://www.eclemma.org/jacoco/trunk/doc/

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.

Marc R. Hoffmann

unread,
Oct 7, 2016, 6:56:16 AM10/7/16
to jac...@googlegroups.com
Works for both!

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.

yashwanth koundinya

unread,
Oct 7, 2016, 7:04:31 AM10/7/16
to JaCoCo and EclEmma Users
Please let me know whether the below configuration is correct or any changes are required? This is present in root pom.xml.
 
<build>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>prepare-agent</id>
<goals>
 <goal>prepare-agent</goal> 
</goals>
</execution>
        </executions>
      </plugin>
    </plugins>
  </build>

yashwanth koundinya

unread,
Oct 7, 2016, 1:26:08 PM10/7/16
to JaCoCo and EclEmma Users
Hi Team,

Thanks a lot for your help. Now everything goes good. I have a good coverage report. :)

Thanks
Yashwanth 

Marc Hoffmann

unread,
Oct 7, 2016, 1:50:47 PM10/7/16
to jac...@googlegroups.com
Good to hear!

Thx for the feedback,
-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.

yashwanth koundinya

unread,
Oct 8, 2016, 2:38:34 AM10/8/16
to JaCoCo and EclEmma Users
Hi Marc,

Everything looks good; because we are using PowerMock in few tests only and not for every class, I see errors on console for classes which do not use PowerMock saying that the class is already instrumented. Being we have around 3000+ classes in the project, Error log is too huge. Sometimes we are seeing Out Of Memory error during the build.

Is there any way we can check to instrument for only classes which are using PowerMock and skip others (something like including and excluding)? 

If yes, which way can we include or exclude the same. Should we statically include the classes or packages which are written using PowerMock or can we provide some additional config so that instrumentation happens only for classes which are using PowerMock dynamically?

For any of the two possible ways above please provide a sample code.

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