PowerMock and ant

493 views
Skip to first unread message

Bremse

unread,
Nov 16, 2009, 12:06:20 PM11/16/09
to PowerMock
We are using ant in our project to make builds. Unfortunatelly I
cannot get my tests (which use PowerMock) working with ant and Eclipse
at the same time.
Using:
import org.powermock.modules.junit4.legacy.PowerMockRunner;
tests are able to run from Eclipse IDE but fail from ant with
exception:
java.lang.NoClassDefFoundError: org/junit/internal/runners/
TestClassRunner

From other hand changing the import above to
import org.powermock.modules.junit4.PowerMockRunner;
makes tests runnable from ant but then they fail from Eclipse IDE with
exception desribed in FAQ section:
java.lang.SecurityException: class
"org.junit.internal.runners.TestClass"'s signer information does not
match signer information of other classes in the same package

What did I wrong?
ant 1.7.0
<junit printsummary="on" haltonfailure="no" fork="yes"
showoutput="false" reloading="false" timeout="300000"
forkmode="perBatch" dir="${project_home}\java"
failureproperty="tests.failed">
<classpath>
<pathelement location="${tstsrc}"/>
<pathelement path="${testclasspath};${classpath}"/>
</classpath>
.....
</junit>

Any ideas?

Johan Haleby

unread,
Nov 16, 2009, 2:55:55 PM11/16/09
to powe...@googlegroups.com
Hi,

I've experienced the same thing once. You must make sure that you have the correct jars on classpath and that they're imported on the classpath in the correct order. In my case there were two junit jars in classpath in ant and the wrong one had precedence over the correct one.

/Johan

Bremse

unread,
Nov 17, 2009, 4:40:34 AM11/17/09
to PowerMock
Thank you Johan for advice. I had the same reason: old JUnit library
in Eclipse which was included into project

On Nov 16, 9:55 pm, Johan Haleby <johan.hal...@gmail.com> wrote:
> Hi,
>
> I've experienced the same thing once. You must make sure that you have the
> correct jars on classpath and that they're imported on the classpath in the
> correct order. In my case there were two junit jars in classpath in ant and
> the wrong one had precedence over the correct one.
>
> /Johan
>
Reply all
Reply to author
Forward
0 new messages