Spy object by Mockito in Spring
It might be problem with the dependencies. The powermock-api-mockito
has compile time dependency on mockito-core
version 1.10.19
, but you have also defined a dependency on version 2.0.44-beta
. This might be a classpath problem. Try removing the explicit dependency on version 2.0.44-beta
.
In the release 2.0.32-beta Mockito team moved cglib classes into separated jar. But PowerMock still depends on classes which have been moved, so you get java.lang.NoClassDefFoundError.
In release 1.6.2 Mockito classes was copied into PowerMock, but not all. As workaround I may suggest clone, build and add to classpath the mockito-cglib (https://github.com/mockito/mockito-cglib).
The PowerMock will have supported Mockito 2 API since 1.6.5 which will have been released by the end of the May, but will still use cglib. The full Mockito 2 with Bytebuddy will be supported in release after 1.6.5.
Developer Guide for Migration to Mockito 2