NoSuchMethodError with createMockHandler method.

4,653 views
Skip to first unread message

Mark Gabb

unread,
Dec 11, 2017, 3:50:20 AM12/11/17
to PowerMock
Hi,

I'm using the following versions of Mockito and PowerMockito but am having issues with unit testing some classes with regards to what looks like compatibility issues.

        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito2</artifactId>
            <version>1.7.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>1.7.3</version>
            <scope>test</scope>
        </dependency>
          <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.13.0</version>
            <scope>test</scope>
        </dependency>


When I run the tests I get a NoSuchMethodError

java.lang.NoSuchMethodError: org.mockito.internal.handler.MockHandlerFactory.createMockHandler(Lorg/mockito/mock/MockCreationSettings;)Lorg/mockito/internal/InternalMockHandler;
at org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.createMethodInvocationControl(DefaultMockCreator.java:114)
at org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.createMock(DefaultMockCreator.java:69)
at org.powermock.api.mockito.internal.expectation.AbstractConstructorExpectationSetup.createNewSubstituteMock(AbstractConstructorExpectationSetup.java:48)
at org.powermock.api.mockito.internal.expectation.AbstractConstructorExpectationSetup.withNoArguments(AbstractConstructorExpectationSetup.java:98)
at com.alcumusgroup.accreditation.commands.services.DocumentServiceTest.testUploadAccreditationSubmissionReportValidBytesIOExceptionOccursOnUploadLogError(DocumentServiceTest.java:40)


When I use 2.0.0-beta.5 instead of 1.7.3 for PowerMock then the tests work however I don't want to use beta software in our project if possible.

Anyone have any ideas where I can get some good information on what is compatible with what so I can resolve the issues above please?

Kind regards,

Mark

Zagretdinov Arthur

unread,
Dec 11, 2017, 3:55:25 AM12/11/17
to powe...@googlegroups.com
PowerMock 1.7.3 is compatible only with 2.8.0-2.8.9


PowerMock 2.x will work with all Mockito 2.x upper than 2.10.0 (Mockito and PowerMock team did a huge job to achieve this). But PowerMock 2.x still on beta stage. 

Best regrads,
Arthur Zagretdinov
--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to powermock+...@googlegroups.com.
To post to this group, send email to powe...@googlegroups.com.
Visit this group at https://groups.google.com/group/powermock.
For more options, visit https://groups.google.com/d/optout.

Mark Gabb

unread,
Dec 11, 2017, 6:30:47 AM12/11/17
to PowerMock
Thank you Arthur, I've made changes to match what you suggested and it's worked! Thank you.

Kind regards,

Mark
Reply all
Reply to author
Forward
0 new messages