0

I am using Mockito to run tests in an android module. My tests works fine before adding the configuration for mock-maker-inline in src/test/resources/mockito-extensions file. But after adding this configuration some of my tests are not working any more.

Here is the code I'm using to mock my class.

private static Fragment createMock() {
    final Fragment stubFragment =
            mock(Fragment.class, withSettings().extraInterfaces(MyInterface.class));
    when(((MyInterface) stubFragment).getFragment()).thenReturn(stubFragment);
    return stubFragment;
}

And this is the exception

org.mockito.exceptions.misusing.MissingMethodInvocationException

I don't need Mockito inline for this class as it works without it but I need it for some other classes in the same module. Any help or suggestions will be appreciated

Alireza Ahmadi
  • 5,122
  • 7
  • 40
  • 67

0 Answers0