首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Junit Jupiter 5 (Intellij)无法识别导入org.junit.jupiter.api.Test类

Junit Jupiter 5 (Intellij)无法识别导入org.junit.jupiter.api.Test类
EN

Stack Overflow用户
提问于 2021-09-20 08:27:45
回答 1查看 170关注 0票数 0

我使用gradle init创建了一个简单的java应用程序。我正在使用Intellij 2021.2.2。

当我构建这个项目时,我得到了关注。

代码语言:javascript
复制
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java application project to get you started.
 * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
 * User Manual available at https://docs.gradle.org/7.2/userguide/building_java_projects.html
 */

plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    id 'application'
    id 'java'
}

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
}

dependencies {
    testImplementation('org.junit.jupiter:junit-jupiter:5.5.2')
}

application {
    // Define the main class for the application.
    mainClass = 'JunitPOC.App'
}


test{
    useJUnitPlatform()
}

tasks.named('test') {
    // Use JUnit Platform for unit tests.
    useJUnitPlatform()
}

查看依赖项,我可以看到所有依赖项都在测试编译&运行时路径中。

更深入地查看源代码,我发现Intellij并没有正确地为junit.api jar选择源文件,只是为了测试类。我能引用的所有其他类。

有没有人遇到过这个问题?任何帮助都会得到重视。

EN

回答 1

Stack Overflow用户

发布于 2021-09-22 05:55:11

在进入文件>管理IDE设置>恢复默认设置后,我可以让它工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69251272

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档