【问题标题】:Org.Junit is unresolved in Spring boot version 2.3Spring boot 2.3 版本未解决 Org.Junit
【发布时间】:2021-03-29 17:43:25
【问题描述】:

我创建了一个 SPRING BOOT 应用程序版本 2.3.2,当我尝试使用 JUNIT 5 编写单元测试时。STS IDE 中的单元测试类显示 org.junit 未解析。 这是我对 build.gradle 的依赖

dependencies {
    compile "org.springframework.boot:spring-boot-starter-actuator:2.3.2.RELEASE"
    compile "org.springframework.boot:spring-boot-starter-web:2.3.2.RELEASE"
    compile "org.springframework.boot:spring-boot-starter-log4j2:2.3.2.RELEASE"
    testCompile "org.springframework.boot:spring-boot-starter-test:2.3.2.RELEASE"
}

测试类:

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
      
class PasswordvaultComponentTest {
      
    @Test void test()
    {
        fail("Not yet implemented");
    }      
}

由于 JUNIT JUPITER 已经捆绑到 SPRING BOOT 2.3.2 中。我不需要在 gradle 中明确提供 Junit Jupiter 依赖项。我在这里缺少任何其他配置吗?非常感谢任何帮助。

【问题讨论】:

    标签: spring-boot junit junit5 spring-test


    【解决方案1】:

    我在包 src/main/java 中有我的测试类。所以我把我的测试类移动到包 src/test/java 并且依赖被解决了。

    【讨论】:

      猜你喜欢
      • 2020-10-01
      • 2022-06-24
      • 2018-06-18
      • 2018-01-23
      • 2020-11-13
      • 1970-01-01
      • 2017-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多