zoukankan      html  css  js  c++  java
  • Maven

    总结

    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

    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, 需要做以下三步:

    1. 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.)

    2. Direct maven-surefire-plugin to exclude your integration tests (see example below) or to include only non-integration tests (see default includes).

    3. Direct maven-failsafe-plugin to only include your integration tests instead of default includes.

    			<!--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>
    

      

  • 相关阅读:
    Serverless:这真的是未来吗?(二)
    阿里云 EDAS 3.0 助力唱鸭提升微服务幸福感
    520,一份给程序员的“硬核”脱单秘籍
    稳定性之故障应急处理流程
    殷浩详解DDD:领域层设计规范
    Vineyard 加入 CNCF Sandbox,将继续瞄准云原生大数据分析领域
    【开通指南】 实时计算 Flink 全托管版本
    【HTML】html5 canvas全屏烟花动画特效
    【HTML】中国天气天气插件调用
    【Python】求n!
  • 原文地址:https://www.cnblogs.com/frankcui/p/13970539.html
Copyright © 2011-2022 走看看