# org.mockito.exceptions.misusing.UnnecessaryStubbingException: Unnecessary stubbings detected in test class

- **ID:** `java/mockito-strict-stubbing-unnecessary`
- **Domain:** java
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Stubs defined with when() but never used during the test execution.

## Version Compatibility

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

## Workarounds

1. **Use lenient() for specific stubs** (85% success)
   ```
   lenient().when(mock.method()).thenReturn(value);
   ```
2. **Remove unused stubs** (90% success)
   ```
   // Remove the stub line that is never used
// when(mock.method()).thenReturn(value);
   ```

## Dead Ends

- **Removing all stubs blindly** — May cause test to fail if stubs were actually needed but not triggered. (50% fail)
- **Adding @MockitoSettings(strictness = Strictness.LENIENT) globally** — Hides real issues, may lead to false positives. (40% fail)
