# org.mockito.exceptions.misusing.UnfinishedStubbingException: Unfinished stubbing detected here: doReturn().when()

- **ID:** `java/mockito-doreturn-when-mismatch`
- **Domain:** java
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

doReturn().when() syntax is used incorrectly, such as missing method call or wrong order.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 8+ | active | — | — |

## Workarounds

1. **Complete the doReturn().when() chain correctly** (90% success)
   ```
   doReturn("value").when(mock).method();
   ```
2. **Use when().thenReturn() for non-void methods** (85% success)
   ```
   when(mock.method()).thenReturn("value");
   ```

## Dead Ends

- **Switching to when().thenReturn() blindly** — May not work for void methods or spies. (50% fail)
- **Adding extra doReturn calls** — Compounds the issue; still unfinished. (60% fail)
