Error while using PowerMockito.whenNew()

Posted by Ankush on Stack Overflow See other posts from Stack Overflow or by Ankush
Published on 2010-03-16T21:58:48Z Indexed on 2010/03/16 22:01 UTC
Read the original article Hit count: 762

Filed under:
|
|
|
|

I am using PowerMockito(1.3.6) with Mockito(1.8.3) and Junit(4.7) for testing. I am quite stuck on an error:

[junit] Testcase: testNextPNRFromQueueHappyPath(com.orbitz.galileo.host.robot.GalpoQueueConnectionTest): Caused an ERROR [junit] org/mockito/internal/IMockHandler [junit] java.lang.NoClassDefFoundError: org/mockito/internal/IMockHandler [junit] at org.powermock.api.mockito.internal.expectation.DefaultConstructorExpectationSetup.createNewSubsituteMock(DefaultConstructorExpectationSetup.java:80) [junit] at org.powermock.api.mockito.internal.expectation.DefaultConstructorExpectationSetup.withArguments(DefaultConstructorExpectationSetup.java:48) [junit] at com.orbitz.galileo.host.robot.GalpoQueueConnectionTest.testNextPNRFromQueueHappyPath(GalpoQueueConnectionTest.java:62) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

My class under test : GalpoQueueConnection is basically creating a new object of another class : QueueReadBuilder. I am trying to do something like:

@RunWith(PowerMockRunner.class)

@PrepareForTest({GalpoQueueConnection.class, ApolloProcUtils.class}) public class GalpoQueueConnectionTest extends TestCase{ @Test public void testNextPNRFromQueueHappyPath() throws Exception { QueueReadBuilder mockBuilder = mock(QueueReadBuilder.class); PowerMockito.whenNew(QueueReadBuilder.class).withArguments(anyString(), anyString(), anyString()).thenReturn(mockBuilder); } }

It seems like somehow powermockito is trying to call IMockHandler, and I looked at Mockito 1.8.3 api, and there isn't any.

Any suggestions/ clues would be welcome.

© Stack Overflow or respective owner

Related posts about mocking

Related posts about mockito