Search code examples
javajunitmockito

adding Mockito gives logging error when running a test


I'm using JUnit 5 in my Spring project and would like to do some mocking using Mockito. So I've I added a couple Mockito dependencies: mockito-core 2.21.0 and mockito-junit-jupiter 4.0.0.

Then based on some guidance I found somewhere I added this to my very simple test class:

@ExtendWith(MockitoExtension.class)

But when I run the test I get this confounding error:

java.lang.NoSuchMethodError: org.mockito.internal.configuration.plugins.Plugins.
    getMockitoLogger()Lorg/mockito/plugins/MockitoLogger;
...

But I'm not using the MockitoLogger class anywhere, or at least not explicitly. So what could cause this strangeness?


Solution

  • For some reason, switching to mockito-core-2.23.0 seemed to resolve this for me. I took that approach based on advice given here for a different issue.