# 中断异常：睡眠被中断

- **ID:** `java/mockito-verify-timeout-interrupted`
- **领域:** java
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

带有超时的 verify 使用后台线程，该线程被中断，通常由于测试超时或线程问题。

## 版本兼容性

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

## 解决方案

1. **Increase test timeout to accommodate verify timeout** (85% 成功率)
   ```
   @Timeout(10)
@Test
void asyncTest() {
    verify(mock, timeout(5000)).method();
}
   ```
2. **Use awaitility library for async tests** (90% 成功率)
   ```
   await().atMost(5, SECONDS).untilAsserted(() -> {
    verify(mock).method();
});
   ```

## 无效尝试

- **Removing timeout from verify** — May cause test to hang indefinitely. (60% 失败率)
- **Catching InterruptedException and ignoring** — Hides real threading issues; test may pass incorrectly. (50% 失败率)
