原文链接
http://my.oschina.net/dlpinghailinfeng/blog/301136
maven单元测试与集成测试
- 通过maven的Profile
- 配置生命周期 通过maven-surefire-plugin的生命周期配置不同的测试范围
如下使用的是方式2
unit包中包含的是单元测试
integration包种包含的是集成测试
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>run-integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/integration/**/*.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>run-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/unit/**/*.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<dependentWarExcludes>WEB-INF/lib</dependentWarExcludes>
</configuration>
</plugin>
</plugins>