java
runtime_error
ai_generated
true
org.mockito.exceptions.misusing.UnfinishedStubbingException: Unfinished stubbing detected here: doReturn().when()
ID: java/mockito-doreturn-when-mismatch
80%Fix Rate
85%Confidence
0Evidence
2024-02-28First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 8+ | active | — | — | — |
Root Cause
doReturn().when() syntax is used incorrectly, such as missing method call or wrong order.
generic中文
doReturn().when() 语法使用不正确,例如缺少方法调用或顺序错误。
Workarounds
-
90% success Complete the doReturn().when() chain correctly
doReturn("value").when(mock).method(); -
85% success Use when().thenReturn() for non-void methods
when(mock.method()).thenReturn("value");
Dead Ends
Common approaches that don't work:
-
Switching to when().thenReturn() blindly
50% fail
May not work for void methods or spies.
-
Adding extra doReturn calls
60% fail
Compounds the issue; still unfinished.