类不存在

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

 

 原因分析  是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() {
    }

}

 

相关文章:

  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2021-09-29
  • 2021-04-11
  • 2021-08-19
  • 2021-09-18
  • 2022-01-05
猜你喜欢
  • 2021-07-10
  • 2021-05-29
  • 2021-04-18
  • 2021-05-30
  • 2022-02-28
  • 2021-07-15
  • 2021-07-20
相关资源
相似解决方案