Trouble with Maven Tycho and executing PowerMock enabled test cases

91 views
Skip to first unread message

robert.varttinen

unread,
Nov 30, 2009, 10:45:13 AM11/30/09
to PowerMock
Hi everybody!
We are trying to execute test cases with Tycho/Maven. Executing the
"pure" JUnit cases, i.e. JUnit only, test cases execute as expected.
When it comes to those using PowerMock ( @RunWith
( PowerMockRunner.class ) ) it results in ClassCastExceptions being
thrown.

We are using the latest release of PowerMock; 1.3.1 and the
corresponding JUnit 4.7. Any ideas? Have we missed something obvious?
Something we should check, but missed? Any pointers are appreciated.

Thanks in advance,


Robert

P.S. The stacktrace;

java.lang.ClassCastException:
org.powermock.modules.junit4.PowerMockRunner cannot be cast to
org.junit.runner.Runner
at org.junit.internal.builders.AnnotatedBuilder.buildRunner
(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass
(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass
(RunnerBuilder.java:57)
at
org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass
(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass
(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner
(ClassRequest.java:24)
at org.apache.maven.surefire.junit4.JUnit4TestSet.<init>
(JUnit4TestSet.java:45)
at
org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet
(JUnit4DirectoryTestSuite.java:56)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets
(AbstractDirectoryTestSuite.java:96)
at org.apache.maven.surefire.Surefire.createSuiteFromDefinition
(Surefire.java:209)
at org.apache.maven.surefire.Surefire.run(Surefire.java:156)
at org.codehaus.tycho.surefire.osgibooter.OsgiSurefireBooter.run
(OsgiSurefireBooter.java:68)
at org.codehaus.tycho.surefire.osgibooter.HeadlessTestApplication.run
(HeadlessTestApplication.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException
(EclipseAppContainer.java:574)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run
(EclipseAppHandle.java:195)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication
(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start
(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:386)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)



Johan Haleby

unread,
Nov 30, 2009, 2:29:05 PM11/30/09
to powe...@googlegroups.com
Hi,

I've never seen this myself but I wonder if it may have something todo with classloading. For some reason it seems like org.powermock.modules.junit4.PowerMockRunner and org.junit.runner.Runner are loaded by different classloaders. I don't know why this should happen though because PowerMock's CL loads junit in the same CL as PowerMockRunner.

/Johan




--

You received this message because you are subscribed to the Google Groups "PowerMock" group.
To post to this group, send email to powe...@googlegroups.com.
To unsubscribe from this group, send email to powermock+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/powermock?hl=en.



Reply all
Reply to author
Forward
0 new messages