2015-05-13 20 views
5

運行我的測試時,我得到一個錯誤這樣的:在TestClass中找不到測試您沒有忘記@Test註釋嗎?

org.mockito.exceptions.base.MockitoException: 

No tests found in TestCase 
Haven't you forgot @Test annotation? 

我當然有@Test註釋的方法。我究竟做錯了什麼?

+0

我不明白這個問題是如何脫離主題。請澄清你爲什麼這麼想,以便我可以改進它。 –

+0

我使用的是當前的JUnit 5和Mockito v1.10.19。面對同樣的問題,儘管用公共訪問說明符編寫測試方法。有什麼建議? –

+0

@ParameshKorrakuti從未使用Junit 5.如果沒有關於Junit5的問題,只需創建一個新問題。 –

回答

19

的方法需要被顯式聲明爲public

@Test 
public void asdf() { 
    asdf... 
} 
0

進口的junit包TestNG中包代替。

1

您需要更改的唯一方法是方法簽名。使其公開如下...

@Test 
public void testMethod(){ 
    System.out.println("This is a test method"); 
} 
相關問題