Get 0% coverage for the Class which is used by Spring injection

59 views
Skip to first unread message

lele...@gmail.com

unread,
Jun 23, 2017, 4:41:03 AM6/23/17
to JaCoCo and EclEmma Users
Hi,
For example, I have three classes, ClassA, ClassB, ClassC. And these classes in the same package. ClassB and ClassC is used by ClassA though spring injection.
First config the jacoco in tomcat:
[export CATALINA_OPTS="-javaagent:/javacoverage/jacoco/lib/jacocoagent.jar=includes=com.**.*,output=tcpserver,port=8081,address=10.2.60.247"].
Second, run the test case and get the jacoco.exec.
Third, get the Report with jacoco.exec and sourceCode.
Then, I found a strange result. It only have coverage data for the ClassA, however the coverage data for ClassB and ClassC are 0%.
Until now, I could't find out waht's going on. Would you like to help me solve this problem?

Thanks

Evgeny Mandrikov

unread,
Jun 23, 2017, 5:17:05 AM6/23/17
to JaCoCo and EclEmma Users, lele...@gmail.com
Hi,

To speedup understanding of your issue, please provide minimalistic, compilable and easily runnable example demonstrating your issue. Otherwise, not being a daily user of spring, cost to build something similar to your setup is pretty high and without guarantees to see the exact same behavior as you experience.

lele...@gmail.com

unread,
Jun 23, 2017, 5:49:02 AM6/23/17
to JaCoCo and EclEmma Users, lele...@gmail.com

For more detail information:
Spring Config:

<bean id="ClassA" class="com.**.basebiz.userregister.core.UserRegisterByTokenBiz">
<property name="ClassB" ref="ClassB"></property>
<property name="ClassC" ref="ClassC"></property>
</bean>

In [ClassA] class:
UserRegisterByTokenResponseType response = ClassB.checkRequest(request);
String bindUid = ClassC.getBindUidByMobile(mobilephone,countryCode);

POM config:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
- <configuration>
<dataFile>${session.executionRootDirectory}/code-coverage/jacoco.exec</dataFile>
</configuration>
- <executions>
- <execution>
<id>jacoco-report</id>
<phase>verify</phase>
- <goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>

Evgeny Mandrikov

unread,
Jun 24, 2017, 3:59:59 PM6/24/17
to JaCoCo and EclEmma Users, lele...@gmail.com
Sorry, but partial excerpts can not be called compilable and definitely not an easily runnable example. Please provide complete example.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages