# org.junit.jupiter.api.extension.TestWatcher: testTimedOut - test timed out after 5000ms

- **ID:** `java/junit-test-execution-timeout`
- **Domain:** java
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Test method took longer than specified timeout due to infinite loops, blocking calls, or slow performance.

## Version Compatibility

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

## Workarounds

1. **Debug with stack trace on timeout** (85% success)
   ```
   // Add @Timeout annotation and check thread dump on failure
@Timeout(5)
@Test
void slowTest() {
    // code
}
   ```
2. **Use assertTimeout with preemptive flag** (90% success)
   ```
   assertTimeoutPreemptively(Duration.ofSeconds(5), () -> {
    // test code
});
   ```

## Dead Ends

- **Increasing timeout value without investigation** — May hide performance bugs or infinite loops. (70% fail)
- **Removing @Timeout annotation** — Test may run indefinitely in CI. (60% fail)
