gpt4 book ai didi

maven - 集成测试前启动Apache tomcat服务器

转载 作者:行者123 更新时间:2023-12-04 20:06:26 24 4
gpt4 key购买 nike

在过去的 4 天里,我一直在寻找解决方案,并将这个问题作为赏金提出,但仍然没有得到我的答案。

我在 pf pom.xml 文件的帮助下成功的地方:-
a) 使用命令手动启动 tomcat 服务器,即 mvn tomcat7:run。这个命令也
帮助我将我的 war 文件部署到 tomcat 服务器并启动服务器。
b) 在 Eclipse 上使用 testng.xml 文件配置运行我的集成测试。

我在帮助 pf pom.xml 文件中失败的地方:-

a) 自动启动 tomcat 服务器。
b) 运行所有集成测试。
c) 停止 tomcat 服务器。

这个问题是我发布的,但找不到答案
Starting apache server before integration testing not working

请帮助我错的地方。

最佳答案

最小的 POM

这是我用来实现您想要的最小 POM 文件。如果它不适合您,请发布 mvn -X clean verify 的输出就像@BrennaFlood 说的那样。 tomcat7-maven-plugin 和 maven-failsafe-plugin 的配置取自 http://tomcat.apache.org/maven-plugin-2.2/run-mojo-features.html#Use_it_with_selenium_mojohttp://maven.apache.org/surefire/maven-failsafe-plugin/usage.html , 分别。

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>tomcat-with-failsafe</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<prerequisites>
<maven>2.2.1</maven>
</prerequisites>

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>tomcat7-run</id>
<goals>
<goal>run-war-only</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<fork>true</fork>
</configuration>
</execution>
<execution>
<id>tomcat7-shutdown</id>
<goals>
<goal>shutdown</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

关于maven - 集成测试前启动Apache tomcat服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25356685/

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