如何针对不同级别的maven生命周期分离单元测试和集成测试

时间:2016-10-21 09:32:13

标签: maven maven-2 integration-testing maven-plugin maven-surefire-plugin

这是我从pom.xml文件

的插件配置
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <executions>
      <execution>
        <id>run-unit-tests</id>
        <phase>test</phase>
        <goals>
          <goal>test</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <skipITs>true</skipITs>
      <skipUTs>false</skipUTs>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.19.1</version>
    <executions>
      <execution>
        <id>run-integration-tests</id>
        <phase>integration-test</phase>
        <goals>
          <goal>integration-test</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <skipITs>false</skipITs>
      <skipUTs>false</skipUTs>
    </configuration>
  </plugin>

我有2个测试类HelloTest.javaWorldITest.java

当我运行mvn clean test时,我希望它只执行 HelloTest 。但是当我执行mvn clean integration-test时,我希望执行 HelloTest WorldITest

但问题是它还在mvn clean test命令中执行了集成测试。

PS:原始代码来自讨论:Prevent unit tests in maven but allow integration tests

0 个答案:

没有答案