簡體   English   中英

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 預期 2 個匹配器,1 個記錄:

[英]org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 2 matchers expected, 1 recorded:

代碼:

Mockito.when(mongoRepo.findByIdAndIsDeleted(objId, false)).thenReturn(responseObj);
// here mongoRepo is MongoRepository and objId is UUID

當我運行測試用例時,出現以下異常:

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 2 matchers expected, 1 recorded:

我也嘗試了其他一些方法,但沒有運氣

我試過的第二個例子:

Mockito.when(mongoRepo.findByIdAndIsDeleted(any(), anyBoolean())).thenReturn(responseObj);
// here mongoRepo is MongoRepository

我試過的第三個例子:

 Mockito.when(mongoRepo.findByIdAndIsDeleted(any(UUID.class), Mockito.eq(false))).thenReturn(responseObj);
// here mongoRepo is MongoRepository

我得到了同樣的例外。 任何幫助,將不勝感激!!

我正在使用 MockitoJUnitRunner

如果我沒記錯的話,Mokito 為這個錯誤提供了額外的解釋,並在運行日志中打印了解釋。 或者您可以檢查是否正確引用了 Matcher 方法,某些具有相同名稱的方法出於不同目的返回 Matcher?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM