edw*_*yte 2 java intellij-idea maven junit5
这篇博客文章说,一旦将junit 5放在类路径上,就可以将鼠标悬停在JUnit 4测试名称上,并且将出现“迁移到JUnit 5”的弹出窗口。我已经将junit-jupiter-api依赖项(version 5.0.3)添加到pom中,并且没有这样的选项可用。
我想念什么?
我猜现在默认情况下禁用此功能。也许是与切换有关的错误。但是您可以手动启用此检查。
尝试右键单击测试名称->分析|按名称运行检查-> JUnit 4测试可以是JUnit 5检查
之后,将快速修复程序“ 迁移到JUnit 5”并按“ 启用检查”。
此迁移对我有用。
对于此检查,您需要:
您需要添加依赖项junit-jupiter-api:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter-engine.version}</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是来自Idea来源的信息:
@Override
public boolean shouldInspect(PsiFile file) {
if (!JavaVersionService.getInstance().isAtLeast(file, JavaSdkVersion.JDK_1_8)) return false;
if (JavaPsiFacade.getInstance(file.getProject()).findClass(JUnitCommonClassNames.ORG_JUNIT_JUPITER_API_ASSERTIONS, file.getResolveScope()) == null) {
return false;
}
return super.shouldInspect(file);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
508 次 |
| 最近记录: |