2016-11-22 328 views
2

我已經pluged了需要依賴爲什麼我會收到一個錯誤「package org.mockito.runners does not exist」?

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

然後,我把我的測試代碼/src/test/java/目錄

然後我試圖推出這樣的測試

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)); 
} 

它工作正常,但如果我添加與Mock相關的任何東西lib

例如@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)); 
    } 

我得到了這樣的錯誤

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 

我在做什麼錯?

如果我僞造的東西隨意問

在此先感謝!

+0

檢查要求的依賴,其範圍 –

+0

是你的測試comlipable?你是否已經試圖清理該項目? –

+0

@PSM你是什麼意思?正如我提到的問題,我已經添加了這種依賴... –

回答

0

確實你的項目是這樣的?: enter image description here

+0

看起來你使用的是Eclipse ...我使用AndroidStudio –

+0

@ AlekseyTimoshchenko是的,我使用eclipse,但AS也可能具有「gradle personality」(或者他們稱之爲項目),只要你在AS中有一個「普通Java」項目,它就不會跟蹤你對Gradle構建的更改文件(S)。 –

0

打開文件>項目結構...

然後手動添加它小號庫的依賴

enter image description here

相關問題