java
data_error
ai_generated
true
java.lang.AssertionError: expected: [1, 2, 3] but was: [1, 2, 4]
ID: java/junit-assertion-expected-actual-mismatch
80%Fix Rate
82%Confidence
0Evidence
2025-01-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 8+ | active | — | — | — |
Root Cause
Test assertion failed due to mismatch between expected and actual values, often from incorrect test data or logic.
generic中文
测试断言失败,因为期望值与实际值不匹配,通常由于测试数据或逻辑错误。
Workarounds
-
90% success Use assertIterableEquals for lists
import static org.junit.jupiter.api.Assertions.assertIterableEquals; assertIterableEquals(expectedList, actualList);
-
85% success Debug by printing actual values
System.out.println("Actual: " + actualList); // Then fix production code
Dead Ends
Common approaches that don't work:
-
Changing expected value to match actual without investigation
80% fail
Hides real bug in production code.
-
Ignoring order in lists without using appropriate matcher
60% fail
AssertEquals checks order; using it for unordered lists causes false failures.