{
  "id": "java/assertion-error",
  "signature": "java.lang.AssertionError: expected:<X> but was:<Y>",
  "signature_zh": "java.lang.AssertionError: 期望值:<X> 但实际值:<Y>",
  "regex": "java\\.lang\\.AssertionError: expected:<(.*)> but was:<(.*)>",
  "domain": "java",
  "category": "assertion_error",
  "subcategory": null,
  "root_cause": "AssertionError is thrown when a Java assertion (assert statement) fails, typically used for debugging or testing to verify invariants, or when a test framework like JUnit detects a failed assertion.",
  "root_cause_type": "generic",
  "root_cause_zh": "AssertionError 在 Java 断言（assert 语句）失败时抛出，通常用于调试或测试以验证不变量，或当测试框架（如 JUnit）检测到断言失败时。",
  "versions": [
    {
      "version": "Java 8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 17",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "JUnit 4.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "JUnit 5.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "AssertionError indicates a programming error; ignoring it allows the bug to persist and may cause unpredictable behavior later.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Assertions are a development-time tool; disabling them does not fix the underlying issue and can lead to silent failures.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Fix the code logic to ensure the assertion condition is true. For example, if the assertion is 'assert x == 10', correct the variable x to equal 10 before the assertion.",
      "success_rate": 0.95,
      "how": "Fix the code logic to ensure the assertion condition is true. For example, if the assertion is 'assert x == 10', correct the variable x to equal 10 before the assertion.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a proper testing framework like JUnit with assertEquals(expected, actual) instead of assert statements, which provides better error messages and is always enabled.",
      "success_rate": 0.9,
      "how": "Use a proper testing framework like JUnit with assertEquals(expected, actual) instead of assert statements, which provides better error messages and is always enabled.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Fix the code logic to ensure the assertion condition is true. For example, if the assertion is 'assert x == 10', correct the variable x to equal 10 before the assertion.",
    "Use a proper testing framework like JUnit with assertEquals(expected, actual) instead of assert statements, which provides better error messages and is always enabled."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.oracle.com/javase/8/docs/api/java/lang/AssertionError.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-04-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}