# java.lang.AssertionError: expected: [1, 2, 3] but was: [1, 2, 4]

- **ID:** `java/junit-assertion-expected-actual-mismatch`
- **Domain:** java
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Test assertion failed due to mismatch between expected and actual values, often from incorrect test data or logic.

## Version Compatibility

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

## Workarounds

1. **Use assertIterableEquals for lists** (90% success)
   ```
   import static org.junit.jupiter.api.Assertions.assertIterableEquals;
assertIterableEquals(expectedList, actualList);
   ```
2. **Debug by printing actual values** (85% success)
   ```
   System.out.println("Actual: " + actualList);
// Then fix production code
   ```

## Dead Ends

- **Changing expected value to match actual without investigation** — Hides real bug in production code. (80% fail)
- **Ignoring order in lists without using appropriate matcher** — AssertEquals checks order; using it for unordered lists causes false failures. (60% fail)
