Maven Fail集成测试问题

时间:2014-07-23 13:06:23

标签: java maven pom.xml maven-failsafe-plugin

我在我的测试源文件夹中有集成测试包,我将它们放在一个名为“integration.com .....”的包中,并以IT前缀结束了集成类,但每当我运行mvn install时它仍会运行我的集成测试,我想做的只是用maven标志运行集成测试。

这是我添加到我的POM.xml

的内容
<plugin>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.17</version>
    <executions>
      <execution>
        <goals>
          <goal>integration-test</goal>
          <goal>verify</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

1 个答案:

答案 0 :(得分:0)

在Maven的默认生命周期中,integration-test阶段在install阶段之前。

要跳过集成测试,请在命令行中使用以下命令:

mvn install -DskipITs

默认情况下跳过集成测试:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.17</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

Maven日志显示正在运行mvn verify时跳过集成测试:

[INFO] --- maven-failsafe-plugin:2.17:integration-test (default) @ maven-failsafe-integration-tests-config ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-failsafe-plugin:2.17:verify (default) @ maven-failsafe-integration-tests-config ---
[INFO] Tests are skipped.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

来源:Maven Failsafe Plugin - Skipping Tests