Maven - maven-surefire-plugin 和 maven-failsafe-plugin
总结
maven-surefire-plugin :运行unit test
maven-failsafe-plugin : 运行integration test (failsafe代表哪怕fail了也安全)
重要参考(必看):
maven-failsafe-plugin官方文档: http://maven.apache.org/surefire/maven-failsafe-plugin/index.html
配置maven-failsafe-plugin以查找不在src / test / java中的集成测试:https://www.it1352.com/1609890.html
Maven使用failsafe实现集成测试:http://www.360doc.com/content/16/0921/17/1073512_592574619.shtml
maven-failsafe-plugin
1 | By default failsafe is configured to only include IT*.java, *IT.java or *ITCase.java. While at the same time, only test sources from src/test/java are compiled. |
如果想识别其他路径下的,其他命名格式的Integratrion Test, 需要做以下三步:
-
Use build-helper-maven-plugin to add src/integationTest/java as test source for maven-compiler-plugin to pick up automatically. (You've already done this in your last attempt.)
-
Direct maven-surefire-plugin to exclude your integration tests (see example below) or to include only non-integration tests (see default includes).
-
Direct maven-failsafe-plugin to only include your integration tests instead of default includes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <!--step 1: include other paths also as test resource--> < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >build-helper-maven-plugin</ artifactId > < version >3.0.0</ version > < executions > < execution > < id >add-integration-test-source-as-test-sources</ id > < phase >generate-test-sources</ phase > < goals > < goal >add-test-source</ goal > </ goals > < configuration > < sources > < source >src/integrationtest/java</ source > </ sources > </ configuration > </ execution > </ executions > </ plugin > <!--step 2: config for unit test--> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-surefire-plugin</ artifactId > < configuration > < includes > < include >**/*Test.java</ include > </ includes > < excludes > < exclude >**/*IntegrationTest.java</ exclude > <!--exclude Integration Test--> </ excludes > <!--<skipTests>true</skipTests>--> <!--if skip all tests--> </ configuration > </ plugin > <!--step 3: config for integration test--> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-failsafe-plugin</ artifactId > < version >3.0.0-M5</ version > < executions > < execution > < goals > < goal >integration-test</ goal > < goal >verify</ goal > </ goals > </ execution > </ executions > < configuration > < includes > < include >**/*IntegrationTest.java</ include > <!--include your own format of integration test--> </ includes > </ configuration > </ plugin > |
posted on 2020-11-13 17:36 frank_cui 阅读(1655) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?