java.lang.NoSuchMethodError: org.mockito.internal.runners.RunnerFactory.createStrict(Ljava/lang/Class;)Lorg/mockito/internal/runners/InternalRunner;

For some reason, your test suite, tries to load the MockitoJunitRunner from the org.mockito.junit contained in the Mockito versions >= 2. O. In that version, the line:

at org.mockito.junit.MockitoJUnitRunner.<init>(MockitoJUnitRunner.java:152)

is doing this:

public MockitoJUnitRunner(Class<?> klass) throws InvocationTargetException {
        //by default, StrictRunner is used. We can change that potentially based on feedback from users
        this(new StrictRunner(new RunnerFactory().createStrict(klass), klass));
    }

and the RunnerFactory that is loaded here is from version 1.x as createStrict has been introduced in Mockito 2.x.

So go through the pom dependency tree and to find what artifact implicitly add the Mockito 2.x dependency to your project and exclude it.

Alternatively.. as a workaround, instead of the @RunWith(MockitoJUnitRunner.class) you can use:

@Before
public void init() {
    MockitoAnnotations.initMocks(this);
}

You can also check out this Mockito cheat sheet to keep all the standards at hand.


The problem lies within your imports. Your imports doesn't include import runner replace the following import

org.mockito.junit.MockitoJUnitRunner

with

 org.mockito.runners.MockitoJUnitRunner;

In Mockito 1.10.19 (which is from 2014), there is no class org.mockito.junit.MockitoJUnitRunner. This was introduced later in 2.x. If you really want to use 1.10.19, you should probably use the then correct class org.mockito.runners.MockitoJUnitRunner which then should work.

But I would strongly recommend using a newer Mockito version instead. mockito-all is simply not the right artifact to depend on anymore. With 2.x this artefact was not maintained anymore.