集成测试前启动Apache tomcat服务器 [英] Starting of the Apache tomcat server before integration test

查看:65
本文介绍了集成测试前启动Apache tomcat服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've been looking for an solution for the last 4 days and raised this question as a bounty but still not getting my answer.

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

Where i've succeeded with the help pf pom.xml file:- a) Starting the tomcat server manually using command i.e mvn tomcat7:run. This command also help me deploying of my war file to tomcat server and starting the server. b) Running my integration tests using testng.xml file configuration on eclipse.

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

Where i'm failed with the help pf pom.xml file:-

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

a) Automatically starting of tomcat server. b) Running all the integration tests. c) Stopping of tomcat server.

这个问题是我发的,但找不到答案在集成测试前启动apache服务器不起作用

This question is posted by me but couldn't find the answer Starting apache server before integration testing not working

请帮助我的错误.

推荐答案

Minimal POM

这是我用来实现您想要的最小 POM 文件.如果它对您不起作用,请像@BrennaFlood 所说的那样发布 mvn -X clean verify 的输出.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,分别.

Minimal POM

Here is a minimal POM file that I used to achieve what you want. If it doesn't work for you, please post the output of mvn -X clean verify like @BrennaFlood said. Configurations for tomcat7-maven-plugin and maven-failsafe-plugin taken from http://tomcat.apache.org/maven-plugin-2.2/run-mojo-features.html#Use_it_with_selenium_mojo and http://maven.apache.org/surefire/maven-failsafe-plugin/usage.html, respectively.

<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>

这篇关于集成测试前启动Apache tomcat服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆