# org.junit.jupiter.api.extension.LifecycleMethodExecutionException: @BeforeAll method 'void setUp()' must be static unless the test class is annotated with @TestInstance(Lifecycle.PER_CLASS)

- **ID:** `java/junit-lifecycle-method-not-static`
- **Domain:** java
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

@BeforeAll or @AfterAll methods are not static in a per-method lifecycle test class.

## Version Compatibility

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

## Workarounds

1. **Make method static** (90% success)
   ```
   @BeforeAll
static void setUp() {
    // static setup
}
   ```
2. **Use @TestInstance(Lifecycle.PER_CLASS)** (85% success)
   ```
   @TestInstance(Lifecycle.PER_CLASS)
class MyTest {
    @BeforeAll
    void setUp() {
        // non-static setup
    }
}
   ```

## Dead Ends

- **Adding static keyword without changing method logic** — Method may access instance fields which are not allowed. (60% fail)
- **Removing @BeforeAll annotation** — Setup logic won't run, causing test failures. (70% fail)
