[雷]单元测试报错--Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test
项目场景:
SpringBoot集成Mybatis-Plus时,进行单元测试时报错
问题描述:
package com.mybatisplusstudty.mapper;import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import static org.junit.jupiter.api.Assertions.*;/*** @Description:* @Author: 涛涛 *^** @Date: 2021/1/7 15:13*/
@SpringBootTest
class UserMapperTest {@Autowiredprivate UserMapper userMapper;@Testvoid test() {userMapper.selectList(null).forEach(System.out::println);}}
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.qcsoft.qcofflinereport.QcOfflineReportApplicationTests
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.136 s <<< FAILURE! - in com.qcsoft.qcofflinereport.QcOfflineReportApplicationTests
[ERROR] initializationError(com.qcsoft.qcofflinereport.QcOfflineReportApplicationTests) Time elapsed: 0.017 s <<< ERROR!
java.lang.Exception: The class com.qcsoft.qcofflinereport.QcOfflineReportApplicationTests is not public.[ERROR] initializationError(com.qcsoft.qcofflinereport.QcOfflineReportApplicationTests) Time elapsed: 0 s <<< ERROR!
java.lang.Exception: Test class should have exactly one public constructor[ERROR] initializationError(com.qcsoft.qcofflinereport.QcOfflineReportApplicationTests) Time elapsed: 0 s <<< ERROR!
java.lang.Exception: Method contextLoads() should be public[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] com.qcsoft.qcofflinereport.QcOfflineReportApplicationTests.initializationError(com.qcsoft.qcofflinereport.QcOfflineReportApplicationTests)
[ERROR] Run 1: QcOfflineReportApplicationTests.initializationError » The class com.qcsoft.qc...
[ERROR] Run 2: QcOfflineReportApplicationTests.initializationError » Test class should have ...
[ERROR] Run 3: QcOfflineReportApplicationTests.initializationError » Method contextLoads() s...
[INFO]
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.250 s
[INFO] Finished at: 2020-03-30T16:11:20+08:00
[INFO] Final Memory: 28M/437M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project qc-offline-report: There are test failures.
[ERROR]
[ERROR] Please refer to D:\fzh\qc-offline-report\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
解决方案:
.解决方案:在原来的maven依赖插件中新加一个maven-surefire-plugin依赖即可
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.22.1</version><configuration><skipTests>true</skipTests></configuration></plugin>
添加之后的pom文件
<plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.22.1</version><configuration><skipTests>true</skipTests></configuration></plugin></plugins>
[雷]单元测试报错--Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test相关推荐
- maven打包报错Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.6.1:cle
问题记录: maven打包报错Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.6.1:cle 解决办法: 这个 ...
- 淘淘商城项目报错 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-
@[TOC](淘淘商城项目报错 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (d ...
- mvn help:effective-pom 报错 Failed to execute goal org.apache.maven.plugins
报错内容 Failed to execute goal org.apache.maven.plugins:maven-help-plugin:2.2:effective-pom (default-cl ...
- maven打包报错 Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.0.2:jar
Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.0.2:jar (default-jar) on project ...
- Maven搭建webapp报错Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.0:generat
在使用maven模板搭建webapp项目时,项目搭建失败 报错如下: 这里显示搭建项目的脚手架和插件等未找到 解决办法: 我们找到自己的maven的仓库,找到搭建webapp的xml文件,我的mave ...
- maven项目打包报错Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default
原因:缺少maven打包插件 解决办法:在pom.xml中加入如下 <build><plugins><plugin><groupId>org.apach ...
- maven编译报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile
在项目的pom.xml中加入: <build><plugins><plugin><groupId>org.springframework.boot< ...
- SpringBoot打包报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile
maven的setting文件内容这块修改成自己使用的JDK版本
- maven package 时报错 Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test
之前启动springboot的项目,报错:Failed to determine suitable jdbc url 但是本地配置文件也配置着spring.datasource.url,目录也没错,想 ...
最新文章
- 独家 | 关于Spark NLP学习,你需要掌握的 LightPipeline(附代码链接)
- 职业生涯中的八大“定位法则”(转)
- 【Boost】boost库中智能指针——weak_ptr
- SAP ABAP实用技巧介绍系列之锁住某个特定的工作进程
- 计算机主机箱外部介绍图,电脑的主机结构是怎样的 电脑主机结构图【图文】...
- 华为虚拟一键部署服务器,一键部署云服务器
- xml--Schema约束
- Python--多线程学习(11.3)
- 15.3D效果,盒阴影和滤镜
- JQuery判断元素是否存在
- shiro 同时实现url和按钮的拦截_Shiro是如何拦截未登录请求的(一)
- Linux C Serial串口编程
- 金蝶K3与IMS系统搭建销售订单交期回复系统
- STM32——滴答定时器设置1us问题
- OC 技术 获取设备的UDID添加到开发者账号(视频)
- 什么是作用域和作用域链以及闭包?
- dmesg 命令详解
- 腾讯敏感词汇大全_有创意的饰品店名,独一无二的饰品店名大全
- 未来的火控计算机,光电火控系统在未来数字化炮兵中的应用
- linux中搜索文件内容关键字--转载哈