我有一个 Maven 项目,它为另一个 Web 应用程序执行集成测试。此应用程序在 tomcat 容器中部署和启动。
对此的配置在“cargo-maven2-plugin”中完成:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<wait>false</wait>
<configuration>
<type>standalone</type>
<properties>
<cargo.hostname>${itest.hostname}</cargo.hostname>
<cargo.protocol>${itest.protocol}</cargo.protocol>
<cargo.servlet.port>${itest.port}</cargo.servlet.port>
<cargo.servlet.uriencoding>UTF-8</cargo.servlet.uriencoding>
<cargo.jvmargs>-Xmx1024m</cargo.jvmargs>
</properties>
</configuration>
<container>
<containerId>tomcat6x</containerId>
<home>${TEST_TOMCAT_HOME}</home>
</container>
<deployer>
<deployables>
<deployable>
<groupId>de.apllicationundertest</groupId>
<artifactId>apllicationundertest</artifactId>
<type>war</type>
<!--
This will test if the app is ready an throw an exception if
the integration tests start before deployment is finished
-->
<pingURL>${itest.protocol}://${itest.hostname}:${itest.port}/${itest.web.context}/main.html
</pingURL>
<pingTimeout>120000</pingTimeout>
<!-- Setting our context for the integration tests -->
<properties>
<context>${itest.web.context}</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
正在测试的(web-)应用程序作为依赖项集成在我的集成测试项目的 pom.xml 中,因此我没有绝对或相对的战争路径。
我的问题是在我的程序运行期间我无法控制 tomcat 容器。虽然我的测试场景需要在一些测试之间停止和重新启动容器(以及重新部署被测应用程序),但 fe 用于检查容器停止后是否仍有一些活动线程或是否仍有一些元素我在缓存中的应用程序,...
- 我想在 java 之外配置容器的启动和停止,最好在 pom.xml 中。那可能吗?
- 我可以指定某些单元测试需要重新启动并执行吗?如何?