It seems that the newest Powermock version doesn't work correctly with Mockito newest version.
I tried to create a mock using static mock using Powermock with mockito-kotlin, but it seems both can't work together, as Powermock works with Mockito version 2.8.9 and the RC1 of mockito-kotlin works with 2.19 at minimum.
The problem seems to be in the dependence to InternalMockHandler, a class that has been deprecated in the last versions.
The method MockHandlerFactory.createMockHandler(settings)(as seen inside DefaultMockCreator.createMethodInvocationControl) now returns a MockHandler, instead of the InternalMockHandler.
I don't know for now if there are more problems, but I would love to continue using both mockito-kotlin and powermock in my projects and would love to see them working together without problems.
If you come to this issue you may want to either downgrade to Mockito 2.8.47 which is the last supported. Or you may want to try powermock 2, however not all beta builds are available on central, the last one is beta 5.
@Megamiun
Please, try PowerMock 2.0.0-RC.1 which has just been released to Maven Central. It works with Mockito 2.23.
https://github.com/powermock/powermock/releases/tag/powermock-2.0.0-RC.1
Hi thekingnothing ,
I also have coverage issue about private method's mock using PowerMock, and have found the associated issue [Fixes #727 Use ByteBuddy to instrument classes instead Javassist:] that has been fixed in the latest version 2.x.
In order to fix my issue, i update to the latest PowerMock 2.0.0.RC.1 together with mockito-core 2.23.0, the UT runs normally. But the above mentioned coverage issue still exists.
Cloud you please help to provide some suggestion?
Many thanks!
Most helpful comment
@Megamiun
Please, try PowerMock 2.0.0-RC.1 which has just been released to Maven Central. It works with Mockito 2.23.
https://github.com/powermock/powermock/releases/tag/powermock-2.0.0-RC.1