gpt4 book ai didi

java - 绑定(bind)到 Maven 中的生命周期不适用于故障安全和集成测试

转载 作者:行者123 更新时间:2023-12-01 12:57:08 24 4
gpt4 key购买 nike

当尝试将故障安全绑定(bind)到生命周期时,根本不会执行任何操作。我已阅读this guidethis related question ,根据这个信息,应该可以让maven执行目标integration-test integration-test中的故障保护,当我在 build/pluginManagement/plugins 中指定它时-pom.xml 中的部分如下所示:

              <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(既不使用mvnintegration-test也不使用mvnverify)

但是,如果我尝试将故障保护与这样的插件规范一起使用(来自here并添加了配置):

             <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 编译故障安全:集成测试运行。但不幸的是,这并没有调用集成前和集成后测试。我现在为此苦苦挣扎了一段时间,但没有任何线索 - 它应该按原样绑定(bind)。

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

最佳答案

您所做的就是仅在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 cause it has already defaults defined 提供包含规则所以没有必要。

关于java - 绑定(bind)到 Maven 中的生命周期不适用于故障安全和集成测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23785443/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com