Org.Junit 在 Spring Boot 2.3 版中未解决

问题描述

我创建了一个 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 依赖项。我在这里是否缺少任何其他配置。非常感谢任何帮助。

解决方法

我在包 src/main/java 中有我的测试类。所以我将我的测试类移到包 src/test/java 并解决了依赖关系。