SpringBoot2 单元测试类的报错问题

问题描述

执行 SpringBoot2 测试时报错,提示找不到 SsmApplicationTests 主类

原因分析

Junit5 升级了框架没有兼容

问题解决

<!--测试模块-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.0.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.0.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>5.5.2</version>
            <scope>test</scope>
        </dependency>

测试类
org.junit.jupiter.api.Test;
替换成
import org.junit.Test;

posted @ 2020-10-23 12:03  Binge-和时间做朋友  阅读(424)  评论(0编辑  收藏  举报