# 未完成的桩代码检测：doReturn().when() 未完成

- **ID:** `java/mockito-doreturn-when-mismatch`
- **领域:** java
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

doReturn().when() 语法使用不正确，例如缺少方法调用或顺序错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 8+ | active | — | — |

## 解决方案

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

## 无效尝试

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