0

当试图将故障安全绑定到生命周期时,根本没有执行任何操作。我已经阅读了这个指南这个相关的问题,根据这个信息,当我在 pom.xml 的 -section 中指定它时,应该可以让 maven 在中执行故障安全的目标,如下所示integration-testintegration-testbuild/pluginManagement/plugins

              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <includes>
                        <include>**/*IT</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <id>failsafe-integration-tests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>failsafe-verify</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

不幸的是,这并不强制 maven 运行 failsafe:integration-test (无论是 mvn integration-test 还是 mvn verify)

但是,如果我尝试像这样使用带有插件规范的故障安全(从这里添加配置):

             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.17</version>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <phase>integration-test</phase>
                        <configuration>
                            <includes>
                                <include>**/*IT</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

至少 maven compile failsafe:integration-test 运行。但不幸的是,这并不称为集成前测试和集成后测试。我现在为此挣扎了一段时间,但不知道 - 它应该按原样绑定。

有谁知道为什么会发生这种情况,或者我该如何解决?

4

1 回答 1

1

您所做的只是在 pluginManagement中定义它,但您必须像这样运行它。pluginManagement 中的定义是固定插件版本的好习惯。

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

除此之外,没有必要为maven-failsafe-plugin 提供包含规则,因为它已经定义了默认值,因此不需要这样做。

于 2014-05-21T14:45:37.887 回答