首页 > 解决方案 > 如何使用 tomcat8-maven-plugin 指定另一个项目中内置的 WAR 进行集成测试?

问题描述

我有两个应用程序(Maven 'war' artifact),我们称它们ApiUi.

我想设置一个完全自动化的集成测试,ApiUi执行集成测试之前在本地启动。

这些应用程序是松散耦合的,因此我不想引入对Apiin Uis build 的任何依赖,反之亦然。

所以我想设置第三个项目,IntegratedQA它将依赖于两个应用程序。

我的初始 POM 包含:

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat8-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <path>/</path>
            </configuration>
            <executions>
                <execution>
                    <id>start-tomcat</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <fork>true</fork>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-tomcat</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>shutdown</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

我的问题是......我究竟如何告诉tomcat启动Api.warUi.war,它们是在单独的项目中构建的?

标签: maventomcatcontinuous-integrationintegration-testing

解决方案


使用 tomcat7-maven-plugin 您可以自定义 tomcat7:deploy 以提供部署到 tomcat 环境中的 war 文件路径。浏览此链接以获取文档。

链接另一个stackoverflow答案,其中指定了它将如何与tomcat 8或9一起使用

Jenkins 将战争文件部署到 Tomcat 8


推荐阅读