PowerMock and Jacoco for Ant Base Project

362 views
Skip to first unread message

praum...@gmail.com

unread,
Jun 17, 2015, 11:56:06 AM6/17/15
to jac...@googlegroups.com
Hi Everyone,

I know this is a known issue while working with Jacoco and PowerMock(or any Mocking framework that modifies the class) together. I have googled online a lot and I did find a nice working example for Jmockit and Jacoco to work together for Maven build project which was posted by Evengy Gudkov but I could not find any example where Jacoco and PowerMock working together in ANT base project. If anyone has ever worked on this or if anyone could post a working example on Jacoco and PowerMock for ant build project it would be really great. I have tried but no luck.

Approach 1:

<junit printsummary="true" failureproperty="junit.failure" fork="true">
<classpath path="${unittest-mockitoJar}" /> ----> I have made sure that PowerMock jar is before Junit jar
<bootclasspath>
<pathelement path="${libdir}/jacoco/jacocoagent.jar}"/>
<pathelement path="C:/gec/10.0.0/gc/instrumented-Classes" /> ----> instrumented classes
</bootclasspath>

<classpath path="${gec-thirdparty-jars}"></classpath>
<sysproperty key="jacoco-agent.destfile" file="${target.exec.file}"/>

<batchtest todir="${test-xml-reports}">
<fileset dir="${classes}" excludes="com/geic/test/util/**,com/geic/test/testlib/**"/> ----> where ${classes} are unit test classes
<formatter type="xml"/>
</batchtest>
</junit>

Approach 2:
<jacoco:coverage destfile="${gecdir}/lib/jacoco/jacoco.exec" xmlns:jacoco="antlib:org.jacoco.ant"> -->
<junit printsummary="true" failureproperty="junit.failure" fork="true">
<classpath path="${unittest-mockitoJar}" />
<classpath path="${libdir}/jacoco/jacocoagent.jar}" />
<classpath path ="C:/gec/10.0.0/gc/instrumented-Classes" /> -->

<classpath path="${gec-thirdparty-jars}"></classpath>

<sysproperty key="jacoco-agent.destfile" file="${target.exec.file}"/>

<batchtest todir="${test-xml-reports}">
<fileset dir="${classes}" excludes="com/gec/test/util/**,com/gec/test/testlib/**"/>
<formatter type="xml"/>
</batchtest>
</junit>
</jacoco:coverage>

Evgeny Mandrikov

unread,
Jun 17, 2015, 3:46:57 PM6/17/15
to jac...@googlegroups.com, praum...@gmail.com, praum...@gmail.com
Hi,

Please don't open consecutively multiple threads on the same subject. Answer was given in thread https://groups.google.com/d/msg/jacoco/t9WwY9_ODnA/W1MUwQ6_7WkJ
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages