【发布时间】:2023-03-05 13:13:01
【问题描述】:
我有一个 maven web 应用程序(Spring+ApacheCXF webservices)和几个集成测试(*IT.java)。我想通过使用 cargo-maven 插件部署战争文件来使用故障安全插件运行集成测试。
这是我的 pom 配置:
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<container>
<containerId>jboss51x</containerId>
<home>C:/jboss-5.1.0.GA</home>
<append>false</append>
<log>${project.build.directory}/logs/jboss51x.log</log>
<output>${project.build.directory}/logs/jboss51x.out</output>
<timeout>300000</timeout>
</container>
<configuration>
<type>existing</type>
<home>C:/jboss-5.1.0.GA/server/default</home>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.jboss.configuration>default</cargo.jboss.configuration>
<cargo.rmi.port>1099</cargo.rmi.port>
<cargo.logging>high</cargo.logging>
</properties>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>admin-services</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deployer-deploy</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>deployer-undeploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>failsafe-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugin>
但问题是 cargo 插件部署了 WAR 文件,并且故障安全插件立即尝试执行 IntegrationTests,到那时应用程序尚未部署,因此测试失败。
使用相同的配置,我可以分两步成功运行集成测试。 1.执行cargo:deployer-deploy 2. 执行集成测试
是否只有在货物插件部署应用程序后才能触发故障保护插件?
【问题讨论】:
标签: web-services integration-testing maven-3 maven-cargo maven-failsafe-plugin