[转]利用maven的surefire插件实现单元测试与集成测试

原文链接
http://my.oschina.net/dlpinghailinfeng/blog/301136

maven单元测试与集成测试

  1. 通过maven的Profile
  2. 配置生命周期 通过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>

posted on 2016-01-13 20:28  laoniu85  阅读(482)  评论(0编辑  收藏  举报

导航