Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on
Posted on 2022-04-22 14:10 ***Pepsi*** 阅读(349) 评论(0) 编辑 收藏 举报解决错误 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.
1.今天对maven项目进行打包,遇到了一个问题,一直没有解决,后来查阅资料解决了,现在记录下:
执行完clean和package后,控制台输入如下错误
[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
2.解决方案:在原来的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.xml
<build> <finalName>qc-offline-report</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </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> </build>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2021-04-22 4.22 Android studio 通过获取验证码用户登陆成功