我已经将 Cargo 设置为在 Maven 配置文件中的预集成测试阶段启动 glassfish 的实例。然后我的测试在集成测试阶段运行,最后,cargo 在集成测试后阶段关闭 tomcat 实例。
当所有测试都通过时,这很好用,但是如果任何测试失败,maven 构建就会失败,并且似乎永远不会达到 post-integration-test 阶段,这会使 glassfish 实例运行(我无法在不杀死它的情况下停止它过程)。
难道我做错了什么?有没有办法确保货物关闭我的 glassfish 实例,即使集成测试阶段失败?
我的行家简介:
<profile>
<!-- run integration tests against the app deployed to a container -->
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<!-- override the exclusion and include integration tests -->
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>***IntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>${cargo.plugin.version}</version>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<container>
<containerId>glassfish3x</containerId>
<artifactInstaller>
<groupId>org.glassfish.main.distributions</groupId>
<artifactId>glassfish</artifactId>
<version>${glassfish.version}</version>
</artifactInstaller>
</container>
<configuration>
<properties>
<cargo.datasource.datasource.mysql>
cargo.datasource.jndi=jdbc/TrackerPool|
cargo.datasource.driver=com.mysql.jdbc.Driver|
cargo.datasource.url=jdbc:mysql://localhost/[database]|
cargo.datasource.transactionsupport=LOCAL_TRANSACTION|
cargo.datasource.username=[username]|
cargo.datasource.password=[password]
</cargo.datasource.datasource.mysql>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>