【发布时间】:2015-12-11 14:33:20
【问题描述】:
有没有办法独立运行集成测试?
我在“集成”组中进行了一些硒测试(在 java 中重新设计),在预集成测试阶段,tomcat 运行 webapp,在集成后测试它关闭。但问题是我需要测试彼此独立。例如,当第一次测试运行时,它会在这里和那里创建一些帖子。在运行第二个测试(在默认的 webapp 上)之前,我需要重置 webapp(清理第一个测试所做的一切)。所有这些都需要自动进行......
这是我来自 pom.xml 的故障安全插件配置。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19</version>
<configuration>
<groups>integration</groups>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
这是集成阶段和 tomcat 初始化的部分...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.190</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>tomcat-run</id>
<goals>
<goal>run</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<webapps>
<webapp>
<groupId>...webapp...</groupId>
<artifactId>...webapp...</artifactId>
<version>${webapp.version}</version>
<type>war</type>
<asWebapp>true</asWebapp>
<contextPath>/</contextPath>
</webapp>
</webapps>
<fork>true</fork>
<port>${tomcat.port}</port>
</configuration>
</execution>
<execution>
<id>tomcat-shutdown</id>
<goals>
<goal>shutdown</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
【问题讨论】:
标签: maven tomcat testng integration maven-failsafe-plugin