Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get an error "package org.mockito.runners does not exist"?

I have pluged up require dependency

testCompile 'org.mockito:mockito-core:1.10.19'

Then I put my test code to /src/test/java/ directory

then I have tried launch such 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 properly, but if I add anything witch associated with 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 got such error

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 forger about something feel free to ask

Thanks in advance!

like image 950
Aleksey Timoshchenko Avatar asked Nov 22 '16 13:11

Aleksey Timoshchenko


1 Answers

It looks like Gradle is not doing it's job. Manually adding the jars may fixed the problem. How to Download and Install jar go here .

and for download mockito use this link

https://mvnrepository.com/artifact/org.mockito/mockito-core/1.10.19

like image 113
P S M Avatar answered Sep 16 '22 14:09

P S M