解决springboot 2.2.5 单元测试类的报错

时间:2020-03-08 19:57:34   收藏:0   阅读:416

类不存在

技术分享图片

 

 原因分析  是junit5升级了 框架没有兼容

解决办法

1 改写pom.xml

<!--测试模块-->
        <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;

最后的测试单元类

package com.wechat.chat;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class ChatApplicationTests {

    @Test
    public void contextLoads() {
    }

}

 

原文:https://www.cnblogs.com/guokefa/p/12444062.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!