Why am I getting the error “package org.mockito.runners does not exist”?… here is a solution to the problem.
Why am I getting the error “package org.mockito.runners does not exist”?
I’ve inserted require dependency
testCompile 'org.mockito:mockito-core:1.10.19'
Then I put my test code in the /src/test/java/
directory
Then I tried to start such a test
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
public class PresenterActivityAcceptNotAcceptTest {
@Test
public void emailValidator_CorrectEmailSimple_ReturnsTrue() {
boolean dd = true;
assertThat(dd, is(true));
}
It works fine, but if I add any witches related to mock
lib
For example@RunWith
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@RunWith(MockitoJUnitRunner.class)
public class PresenterActivityAcceptNotAcceptTest {
@Test
public void emailValidator_CorrectEmailSimple_ReturnsTrue() {
boolean dd = true;
assertThat(dd, is(true));
}
I get an error like this
Error:Execution failed for task ':Application:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Error:(10, 10) error: cannot find symbol class MockitoJUnitRunner
Error:(5, 27) error: package org.mockito.runners does not exist
/home/aleksey/Downloads/NTZ/FittingRoom/Application/src/test/java/com/fittingroom/newtimezone/presenters/PresenterActivityAcceptNotAcceptTest.java
What am I doing wrong?
If I forged something, feel free to ask
Thanks in advance!
Solution
It looks like Gradle didn’t finish its job.
Adding jars manually may resolve the issue.
How to Download and Install jar go here .
To download mockito, use this link
https://mvnrepository.com/artifact/org.mockito/mockito-core/1.10.19