{
  "id": "java/junit-lifecycle-method-not-static",
  "signature": "org.junit.jupiter.api.extension.LifecycleMethodExecutionException: @BeforeAll method 'void setUp()' must be static unless the test class is annotated with @TestInstance(Lifecycle.PER_CLASS)",
  "signature_zh": "生命周期方法执行异常：@BeforeAll 方法 'void setUp()' 必须为静态，除非测试类使用 @TestInstance(Lifecycle.PER_CLASS) 注解",
  "regex": "org\\.junit\\.jupiter\\.api\\.extension\\.LifecycleMethodExecutionException:\\ @BeforeAll\\ method\\ 'void\\ setUp\\(\\)'\\ must\\ be\\ static\\ unless\\ the\\ test\\ class\\ is\\ annotated\\ with\\ @TestInstance\\(Lifecycle\\.PER_CLASS\\)",
  "domain": "java",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "@BeforeAll or @AfterAll methods are not static in a per-method lifecycle test class.",
  "root_cause_type": "generic",
  "root_cause_zh": "在每次方法生命周期的测试类中，@BeforeAll 或 @AfterAll 方法不是静态的。",
  "versions": [
    {
      "version": "8+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding static keyword without changing method logic",
      "why_fails": "Method may access instance fields which are not allowed.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Removing @BeforeAll annotation",
      "why_fails": "Setup logic won't run, causing test failures.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Make method static",
      "success_rate": 0.9,
      "how": "@BeforeAll\nstatic void setUp() {\n    // static setup\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use @TestInstance(Lifecycle.PER_CLASS)",
      "success_rate": 0.85,
      "how": "@TestInstance(Lifecycle.PER_CLASS)\nclass MyTest {\n    @BeforeAll\n    void setUp() {\n        // non-static setup\n    }\n}",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-02-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}