0

I've specified the use of Failsafe in a parent POM. When I run mvn verify on my multi-module build, there is no hint of Failsafe being run - it appears nowhere in the console output.

If I add the same <plugin> definition into a child POM, it does get run (although it complains about not being able to find \failsafe-reports\failsafe-summary.xml).

Surely it should be inheriting which plugins are to be run?

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.15</version>
    <executions>
        <execution>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>
4

2 回答 2

2

首先,您应该像这样在 pluginManagement 中定义它:

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.15</version>
          <executions>
            <execution>
              <id>integration-test</id>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

重要的部分是使用目标integration-testverify而不仅仅是verify。从上面的 Aaprt 你需要像这样定义真正的用法:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

您可以通过添加上面的代码片段在要使用集成测试的每个子模块中单独激活使用。这通常只在少数几个模块中出现。

于 2013-07-24T11:35:51.437 回答
0

您需要添加目标integration-test

              <goals>
                 <goal>integration-test</goal>
                 <goal>verify</goal>
              </goals>

目标验证,只需检查生成的报告 (failsafe-summary.xml) 以查看是否存在测试错误,并导致构建失败。

目标 integration-test 实际上运行测试,至少是匹配的类IT*.javaIT.java并且ITCase.java默认情况下。

于 2013-07-24T11:36:27.817 回答