测试类运行失败:TestEngine with ID ‘junit-jupiter‘ failed to discover tests

2023-12-09 23:30

本文主要是介绍测试类运行失败:TestEngine with ID ‘junit-jupiter‘ failed to discover tests,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

背景:原本我的项目是可以运行的,然后我用另外一台电脑拉了下来,也是可以用的,但是很奇怪,用着用着就不能用了。报了以下错误:

/Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=57098:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/shaonaiyi/.m2/repository/org/junit/platform/junit-platform-launcher/1.8.2/junit-platform-launcher-1.8.2.jar:/Users/shaonaiyi/.m2/repository/org/junit/platform/junit-platform-engine/1.8.2/junit-platform-engine-1.8.2.jar:/Users/shaonaiyi/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/Users/shaonaiyi/.m2/repository/org/junit/platform/junit-platform-commons/1.8.2/junit-platform-commons-1.8.2.jar:/Users/shaonaiyi/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit5-rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/shaonaiyi/IdeaProjects/mybatis-plus-learning/demo/target/test-classes:/Users/shaonaiyi/IdeaProjects/mybatis-plus-learning/demo/target/classes:/Users/shaonaiyi/app/mvn_repos/org/springframework/boot/spring-boot-starter/2.7.13/spring-boot-starter-2.7.13.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/boot/spring-boot/2.7.13/spring-boot-2.7.13.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/spring-context/5.3.28/spring-context-5.3.28.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/spring-aop/5.3.28/spring-aop-5.3.28.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/spring-beans/5.3.28/spring-beans-5.3.28.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/spring-expression/5.3.28/spring-expression-5.3.28.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/boot/spring-boot-autoconfigure/2.7.13/spring-boot-autoconfigure-2.7.13.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/boot/spring-boot-starter-logging/2.7.13/spring-boot-starter-logging-2.7.13.jar:/Users/shaonaiyi/app/mvn_repos/ch/qos/logback/logback-classic/1.2.12/logback-classic-1.2.12.jar:/Users/shaonaiyi/app/mvn_repos/ch/qos/logback/logback-core/1.2.12/logback-core-1.2.12.jar:/Users/shaonaiyi/app/mvn_repos/org/apache/logging/log4j/log4j-to-slf4j/2.17.2/log4j-to-slf4j-2.17.2.jar:/Users/shaonaiyi/app/mvn_repos/org/apache/logging/log4j/log4j-api/2.17.2/log4j-api-2.17.2.jar:/Users/shaonaiyi/app/mvn_repos/org/slf4j/jul-to-slf4j/1.7.36/jul-to-slf4j-1.7.36.jar:/Users/shaonaiyi/app/mvn_repos/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/spring-core/5.3.28/spring-core-5.3.28.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/spring-jcl/5.3.28/spring-jcl-5.3.28.jar:/Users/shaonaiyi/app/mvn_repos/org/yaml/snakeyaml/1.30/snakeyaml-1.30.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/boot/spring-boot-starter-test/2.7.13/spring-boot-starter-test-2.7.13.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/boot/spring-boot-test/2.7.13/spring-boot-test-2.7.13.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/boot/spring-boot-test-autoconfigure/2.7.13/spring-boot-test-autoconfigure-2.7.13.jar:/Users/shaonaiyi/app/mvn_repos/com/jayway/jsonpath/json-path/2.7.0/json-path-2.7.0.jar:/Users/shaonaiyi/app/mvn_repos/net/minidev/json-smart/2.4.11/json-smart-2.4.11.jar:/Users/shaonaiyi/app/mvn_repos/net/minidev/accessors-smart/2.4.11/accessors-smart-2.4.11.jar:/Users/shaonaiyi/app/mvn_repos/org/ow2/asm/asm/9.3/asm-9.3.jar:/Users/shaonaiyi/app/mvn_repos/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:/Users/shaonaiyi/app/mvn_repos/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/shaonaiyi/app/mvn_repos/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar:/Users/shaonaiyi/app/mvn_repos/org/assertj/assertj-core/3.22.0/assertj-core-3.22.0.jar:/Users/shaonaiyi/app/mvn_repos/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/Users/shaonaiyi/app/mvn_repos/org/junit/jupiter/junit-jupiter/5.8.2/junit-jupiter-5.8.2.jar:/Users/shaonaiyi/app/mvn_repos/org/junit/jupiter/junit-jupiter-api/5.8.2/junit-jupiter-api-5.8.2.jar:/Users/shaonaiyi/app/mvn_repos/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/Users/shaonaiyi/app/mvn_repos/org/junit/platform/junit-platform-commons/1.8.2/junit-platform-commons-1.8.2.jar:/Users/shaonaiyi/app/mvn_repos/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/shaonaiyi/app/mvn_repos/org/junit/jupiter/junit-jupiter-params/5.8.2/junit-jupiter-params-5.8.2.jar:/Users/shaonaiyi/app/mvn_repos/org/junit/jupiter/junit-jupiter-engine/5.8.2/junit-jupiter-engine-5.8.2.jar:/Users/shaonaiyi/app/mvn_repos/org/junit/platform/junit-platform-engine/1.8.2/junit-platform-engine-1.8.2.jar:/Users/shaonaiyi/app/mvn_repos/org/mockito/mockito-core/4.5.1/mockito-core-4.5.1.jar:/Users/shaonaiyi/app/mvn_repos/net/bytebuddy/byte-buddy/1.12.23/byte-buddy-1.12.23.jar:/Users/shaonaiyi/app/mvn_repos/net/bytebuddy/byte-buddy-agent/1.12.23/byte-buddy-agent-1.12.23.jar:/Users/shaonaiyi/app/mvn_repos/org/objenesis/objenesis/3.2/objenesis-3.2.jar:/Users/shaonaiyi/app/mvn_repos/org/mockito/mockito-junit-jupiter/4.5.1/mockito-junit-jupiter-4.5.1.jar:/Users/shaonaiyi/app/mvn_repos/org/skyscreamer/jsonassert/1.5.1/jsonassert-1.5.1.jar:/Users/shaonaiyi/app/mvn_repos/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/spring-test/5.3.28/spring-test-5.3.28.jar:/Users/shaonaiyi/app/mvn_repos/org/xmlunit/xmlunit-core/2.9.1/xmlunit-core-2.9.1.jar:/Users/shaonaiyi/app/mvn_repos/com/baomidou/mybatis-plus-boot-starter/3.5.1/mybatis-plus-boot-starter-3.5.1.jar:/Users/shaonaiyi/app/mvn_repos/com/baomidou/mybatis-plus/3.5.1/mybatis-plus-3.5.1.jar:/Users/shaonaiyi/app/mvn_repos/com/baomidou/mybatis-plus-extension/3.5.1/mybatis-plus-extension-3.5.1.jar:/Users/shaonaiyi/app/mvn_repos/com/baomidou/mybatis-plus-core/3.5.1/mybatis-plus-core-3.5.1.jar:/Users/shaonaiyi/app/mvn_repos/com/baomidou/mybatis-plus-annotation/3.5.1/mybatis-plus-annotation-3.5.1.jar:/Users/shaonaiyi/app/mvn_repos/com/github/jsqlparser/jsqlparser/4.3/jsqlparser-4.3.jar:/Users/shaonaiyi/app/mvn_repos/org/mybatis/mybatis/3.5.9/mybatis-3.5.9.jar:/Users/shaonaiyi/app/mvn_repos/org/mybatis/mybatis-spring/2.0.6/mybatis-spring-2.0.6.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/boot/spring-boot-starter-jdbc/2.7.13/spring-boot-starter-jdbc-2.7.13.jar:/Users/shaonaiyi/app/mvn_repos/com/zaxxer/HikariCP/4.0.3/HikariCP-4.0.3.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/spring-jdbc/5.3.28/spring-jdbc-5.3.28.jar:/Users/shaonaiyi/app/mvn_repos/org/springframework/spring-tx/5.3.28/spring-tx-5.3.28.jar:/Users/shaonaiyi/app/mvn_repos/org/projectlombok/lombok/1.18.28/lombok-1.18.28.jar:/Users/shaonaiyi/app/mvn_repos/mysql/mysql-connector-java/5.1.47/mysql-connector-java-5.1.47.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 com.shaonaiyi.demo.DemoApplicationTests,testSelectList
Internal Error occurred.
org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover testsat org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:134)at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:108)at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:80)at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110)at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: org.junit.platform.commons.JUnitException: ClassSelector [className = 'com.shaonaiyi.demo.DemoApplicationTests'] resolution failedat org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener.selectorProcessed(AbortOnFailureLauncherDiscoveryListener.java:39)at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:102)at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:82)at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113)at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:46)at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:69)at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)... 13 more
Caused by: org.junit.platform.commons.PreconditionViolationException: Could not load class with name: com.shaonaiyi.demo.DemoApplicationTestsat org.junit.platform.engine.discovery.ClassSelector.lambda$getJavaClass$0(ClassSelector.java:75)at org.junit.platform.commons.function.Try$Failure.getOrThrow(Try.java:335)at org.junit.platform.engine.discovery.ClassSelector.getJavaClass(ClassSelector.java:74)at org.junit.jupiter.engine.discovery.ClassSelectorResolver.resolve(ClassSelectorResolver.java:66)at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:134)at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185)at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125)at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:91)... 18 more
Caused by: java.lang.ClassNotFoundException: com.shaonaiyi.demo.DemoApplicationTestsat java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)at org.junit.platform.commons.util.ReflectionUtils.lambda$tryToLoadClass$9(ReflectionUtils.java:829)at org.junit.platform.commons.function.Try.lambda$call$0(Try.java:57)at org.junit.platform.commons.function.Try.of(Try.java:93)at org.junit.platform.commons.function.Try.call(Try.java:57)at org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(ReflectionUtils.java:792)at org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(ReflectionUtils.java:748)... 33 more

网上的很多方法都试过了,什么加依赖,排除依赖之类的,但是其实这样的错误,不应该关心项目本身的问题,因为它在另外一台电脑是可以跑的,所以考虑的话可以考虑环境,比如Maven版本、配置、依赖之类的。

最终解决办法:在IDEA中操作一下就可以了,先mvn clean一下Maven依赖,然后再mvn install一下,注意,一定要install,只clean是不行的。

但是,又发现了一个新的问题,测试时,只能新增、查看,不能删除和修改😂😂😂…

尝试加上@Rollback(false),也不生效,删除时影响行数是0,修改时影响行数是1,但结果就是不一样。

这篇关于测试类运行失败:TestEngine with ID ‘junit-jupiter‘ failed to discover tests的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/475420

相关文章

性能测试介绍

性能测试是一种测试方法,旨在评估系统、应用程序或组件在现实场景中的性能表现和可靠性。它通常用于衡量系统在不同负载条件下的响应时间、吞吐量、资源利用率、稳定性和可扩展性等关键指标。 为什么要进行性能测试 通过性能测试,可以确定系统是否能够满足预期的性能要求,找出性能瓶颈和潜在的问题,并进行优化和调整。 发现性能瓶颈:性能测试可以帮助发现系统的性能瓶颈,即系统在高负载或高并发情况下可能出现的问题

如何用Docker运行Django项目

本章教程,介绍如何用Docker创建一个Django,并运行能够访问。 一、拉取镜像 这里我们使用python3.11版本的docker镜像 docker pull python:3.11 二、运行容器 这里我们将容器内部的8080端口,映射到宿主机的80端口上。 docker run -itd --name python311 -p

字节面试 | 如何测试RocketMQ、RocketMQ?

字节面试:RocketMQ是怎么测试的呢? 答: 首先保证消息的消费正确、设计逆向用例,在验证消息内容为空等情况时的消费正确性; 推送大批量MQ,通过Admin控制台查看MQ消费的情况,是否出现消费假死、TPS是否正常等等问题。(上述都是临场发挥,但是RocketMQ真正的测试点,还真的需要探讨) 01 先了解RocketMQ 作为测试也是要简单了解RocketMQ。简单来说,就是一个分

【测试】输入正确用户名和密码,点击登录没有响应的可能性原因

目录 一、前端问题 1. 界面交互问题 2. 输入数据校验问题 二、网络问题 1. 网络连接中断 2. 代理设置问题 三、后端问题 1. 服务器故障 2. 数据库问题 3. 权限问题: 四、其他问题 1. 缓存问题 2. 第三方服务问题 3. 配置问题 一、前端问题 1. 界面交互问题 登录按钮的点击事件未正确绑定,导致点击后无法触发登录操作。 页面可能存在

业务中14个需要进行A/B测试的时刻[信息图]

在本指南中,我们将全面了解有关 A/B测试 的所有内容。 我们将介绍不同类型的A/B测试,如何有效地规划和启动测试,如何评估测试是否成功,您应该关注哪些指标,多年来我们发现的常见错误等等。 什么是A/B测试? A/B测试(有时称为“分割测试”)是一种实验类型,其中您创建两种或多种内容变体——如登录页面、电子邮件或广告——并将它们显示给不同的受众群体,以查看哪一种效果最好。 本质上,A/B测

跨系统环境下LabVIEW程序稳定运行

在LabVIEW开发中,不同电脑的配置和操作系统(如Win11与Win7)可能对程序的稳定运行产生影响。为了确保程序在不同平台上都能正常且稳定运行,需要从兼容性、驱动、以及性能优化等多个方面入手。本文将详细介绍如何在不同系统环境下,使LabVIEW开发的程序保持稳定运行的有效策略。 LabVIEW版本兼容性 LabVIEW各版本对不同操作系统的支持存在差异。因此,在开发程序时,尽量使用

如何在运行时修改serialVersionUID

优质博文:IT-BLOG-CN 问题 我正在使用第三方库连接到外部系统,一切运行正常,但突然出现序列化错误 java.io.InvalidClassException: com.essbase.api.base.EssException; local class incompatible: stream classdesc serialVersionUID = 90314637791991

ORACLE 11g 创建数据库时 Enterprise Manager配置失败的解决办法 无法打开OEM的解决办法

在win7 64位系统下安装oracle11g,在使用Database configuration Assistant创建数据库时,在创建到85%的时候报错,错误如下: 解决办法: 在listener.ora中增加对BlueAeri-PC或ip地址的侦听,具体步骤如下: 1.启动Net Manager,在“监听程序”--Listener下添加一个地址,主机名写计

STM32 ADC+DMA导致写FLASH失败

最近用STM32G070系列的ADC+DMA采样时,遇到了一些小坑记录一下; 一、ADC+DMA采样时进入死循环; 解决方法:ADC-dma死循环问题_stm32 adc dma死机-CSDN博客 将ADC的DMA中断调整为最高,且增大ADCHAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_buffer, ADC_Buffer_Size); 的ADC_Bu

Verybot之OpenCV应用一:安装与图像采集测试

在Verybot上安装OpenCV是很简单的,只需要执行:         sudo apt-get update         sudo apt-get install libopencv-dev         sudo apt-get install python-opencv         下面就对安装好的OpenCV进行一下测试,编写一个通过USB摄像头采