# 测试实例化异常：测试类 [com.example.OuterTest$InnerTest] 必须是静态内部类

- **ID:** `java/junit-nested-test-not-inner`
- **领域:** java
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

@Nested 测试类必须是静态内部类，但当前是非静态的。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 8+ | active | — | — |

## 解决方案

1. **Add static modifier to inner class** (95% 成功率)
   ```
   @Nested
static class InnerTest {
    @Test
    void test() { }
}
   ```
2. **Move test methods to outer class** (80% 成功率)
   ```
   // Remove @Nested and put tests directly in outer class
   ```

## 无效尝试

- **Removing @Nested annotation** — Loses organizational structure; tests may run but not nested. (60% 失败率)
- **Making outer class non-static** — Outer class must be static for @Nested to work. (50% 失败率)
