[powermock] Has anyone been able to run PowerMock from eclipse directly?

962 views
Skip to first unread message

jg

unread,
May 13, 2010, 11:44:59 AM5/13/10
to PowerMock
Eclipse provides many nice features for running JUnit from the IDE.

Has anyone been able to do this?

--
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.

cem.ca...@gmail.com

unread,
May 13, 2010, 11:50:44 AM5/13/10
to powe...@googlegroups.com
Yes, once you have your test set up properly, ie @RunWith(PowerMockRunner.class), just Run As -> Junit Test.

Sent from my Verizon Wireless BlackBerry

jg

unread,
May 13, 2010, 2:30:04 PM5/13/10
to PowerMock
I am running a JUnit test from Eclipse. The JUnit test uses OpenEJB an
this is where I get an error when I run using
@RunWith(PowerMockRunner.class).

Using PowerMock 1.3.8 and OpenEJB 3.1.

This is what appears in the console:

ANNOTATION
@RunWith(PowerMockRunner.class)

@PrepareForTest(FormatMatrixUtil.class)

@LocalClient

public class FormatMatrixUtilMockTest {



}



STACK TRACE
javax.naming.NoInitialContextException: Cannot instantiate class:
org.apache.openejb.client.LocalInitialContextFactory [Root exception
is java.lang.ClassCastException:
org.apache.openejb.client.LocalInitialContextFactory incompatible with
javax.naming.spi.InitialContextFactory]

at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
669)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:
259)

at javax.naming.InitialContext.init(InitialContext.java:235)

at javax.naming.InitialContext.<init>(InitialContext.java:209)

at
com.bcbsnc.onevoice.util.FormatMatrixUtilMockTest.setUpClass(FormatMatrixUtilMockTest.java:
76)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
79)

at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)

at java.lang.reflect.Method.invoke(Method.java:618)

at org.junit.internal.runners.ClassRoadie.runBefores(ClassRoadie.java:
56)

at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:
43)

at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:
133)

at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:
112)

at
org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:
55)

at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:
38)

at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38)

at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
460)

at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
673)

at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
386)

at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
196)

Caused by: java.lang.ClassCastException:
org.apache.openejb.client.LocalInitialContextFactory incompatible with
javax.naming.spi.InitialContextFactory

at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
666)

... 19 more





On May 13, 11:50 am, cem.catik...@gmail.com wrote:
> Yes, once you have your test set up properly, ie @RunWith(PowerMockRunner.class), just Run As -> Junit Test.
>
> Sent from my Verizon Wireless BlackBerry
>
> -----Original Message-----
> From: jg <javi...@us.ibm.com>
> Date: Thu, 13 May 2010 08:44:59
> To: PowerMock<powe...@googlegroups.com>
> Subject: [powermock] Has anyone been able to run PowerMock from eclipse
>
>         directly?
>
> Eclipse provides many nice features for running JUnit from the IDE.
>
> Has anyone been able to do this?
>
> --
> 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 athttp://groups.google.com/group/powermock?hl=en.
>
> --
> 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 athttp://groups.google.com/group/powermock?hl=en.

jg

unread,
May 13, 2010, 2:31:15 PM5/13/10
to PowerMock
When I remove the @RunWith(PowerMockRunner.class) then I do not get
this....

JG

Johan Haleby

unread,
May 14, 2010, 3:00:40 AM5/14/10
to powe...@googlegroups.com
You probably need to make use of @PowerMockIgnore (and this may get you into nasty problems). See the javadoc and see the FAQ for examples. 

/Johan
Reply all
Reply to author
Forward
0 new messages