I am removing Powermock from the project that I am currently working on, so I am trying to rewrite some existing unitary test with only Mockito (mockito-core-2.2.28).
When I run the test, I have the following error:
org.mockito.exceptions.base.MockitoException:
Cannot mock / spy class com.ExternalpackagePath.Externalclass
Mokito cannot scoff / snoop because:
I know this question has already been asked ( How to make fun of the final class using mockito , Dummy objects calling the final classes static methods with Mockito ), but I did not find the answer I'm looking for.
Here is an excerpt of my code:
public class MyClassToTest extends TestCase { private MyClass myClass; @Mock private Externalclass ext;
As mentioned in the Mockito documentation ( https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2 , Β§ Commit unmockable), I added the org.mockito.plugins.MockMaker file. This is my project tree:
- Project
- CSI
- com.packagePath.myPackage
- test
- com.packagePath.myPackage
- resources
- Mockito extensions
- org.mockito.plugins.MockMaker
I am also trying to put the resource directory in "src", in a subdirectory called "test", but the result is still the same.
I thought that mocking the finale was possible with Mockito v2. Does anyone have an idea of ββwhat's missing here?
Thanks!
source share