欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

TestEngine with ID 'junit-vintage' failed to discover tests java.lang.NoClassDefFoundError:

程序员文章站 2022-03-20 10:08:48
...

最开始报错

Failed to resolve org.junit.platform:junit-platform-launcher:1.5.2

添加注解

@SpringBootTest
@RunWith(SpringRunner.class)

其中第二个注解需要依赖

import org.junit.runner.RunWith;

重新添加大部分依赖

<dependency>
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-launcher</artifactId>
    <version>1.0.0-RC2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.0.0-RC2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.vintage</groupId>
    <artifactId>junit-vintage-engine</artifactId>
    <version>4.12.0-RC2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>

报错

 TestEngine with ID 'junit-vintage' failed to discover tests
java.lang.NoClassDefFoundError: 

报错

keyPropertity的con_id在entity中没有set方法
查看entity中存在set方法,将keyProperty="con_id"改为keyProperty="conId"

keyProperty中使用的是entity中的命名而非数据库!之前一直是数据库/entity都是id所以忽略了这一点

如图,测试通过了,但是报错
TestEngine with ID 'junit-vintage' failed to discover tests java.lang.NoClassDefFoundError:
同时发现数据库中不显示
多次刷新还是不显示,重启sqlyog(数据库图形化软件),
发现已经插入4次了

*中查看到相关解释
TestEngine with ID 'junit-vintage' failed to discover tests java.lang.NoClassDefFoundError:
将pom文件中关于测试的依赖更新为如下

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>

重新测试,又显示了这个小框,昨天晚上就一直是这个,昨天等了很久,还是没有解析成功,才开始自力更生的
13:45 Error running 'Rerun Failed Tests': Failed to resolve org.junit.platform:junit-platform-launcher:1.5.2TestEngine with ID 'junit-vintage' failed to discover tests java.lang.NoClassDefFoundError:
度出来的答案
TestEngine with ID 'junit-vintage' failed to discover tests java.lang.NoClassDefFoundError:
先换个网络

相关标签: 整合springboot