java
config_error
ai_generated
true
断言错误:测试 'shouldFail' 已禁用但仍被执行?
java.lang.AssertionError: Test 'shouldFail' is disabled but still executed?
ID: java/junit-disabled-test-still-runs
80%修复率
81%置信度
0证据数
2025-05-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 8+ | active | — | — | — |
根因分析
@Disabled 注解使用不当,或测试运行器因配置忽略 @Disabled。
English
Misuse of @Disabled annotation, or test runner ignores @Disabled due to configuration.
解决方案
-
95% 成功率 Ensure @Disabled is on test method or class
@Disabled("Reason") @Test void test() { // disabled } -
80% 成功率 Check build configuration for JUnit vintage engine
// Ensure no conflicting test runners // Remove junit-vintage-engine if using JUnit 5 only
无效尝试
常见但无效的做法:
-
Removing @Disabled and commenting test
50% 失败
Test becomes dead code; may be forgotten.
-
Using @Ignore instead (JUnit 4 style)
40% 失败
JUnit 5 may not recognize @Ignore unless Jupiter API is used.