【问题标题】:How to run selenium tests as part of maven build phase using Tomcat如何使用 Tomcat 在 maven 构建阶段运行 selenium 测试
【发布时间】:2012-07-04 03:19:24
【问题描述】:

我想实现这个步骤: 1-启动tomcat服务器 2-部署战争 3-启动硒服务器

所以我在我的 pom.xml 文件中使用了这段代码:

<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/maven- 
 v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tests.functional.selenium</groupId>
<artifactId>functionalTestsSelenium</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>functionalTestsSelenium Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium.client-drivers</groupId>
        <artifactId>selenium-java-client-driver</artifactId>
        <version>1.0.2</version>
        <scope>test</scope>
    </dependency>

</dependencies>
<build>
    <finalName>functionalTestsSelenium</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.0.2</version>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>tomcat-maven-plugin</artifactId>
            <version>1.0-beta-1</version>
        </plugin>


        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>selenium-maven-plugin</artifactId>
        </plugin>


        <!-- Start the tomcat server and Deploy the war -->
        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <configuration>
                <wait>false</wait>
                <container>
                    <containerId>tomcat6x</containerId>
                    <type>installed</type>
                    <home>${env.CATALINA_HOME}</home>
                </container>
            </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>


        <!-- Start the selenium server -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>selenium-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>start</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start-server</goal>
                    </goals>
                    <configuration>
                        <background>true</background>
                        <logOutput>true</logOutput>
                    </configuration>
                </execution>
                <execution>
                    <id>stop</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop-server</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
 </plugins>
</build>

所以现在当我运行以下命令时:mvn integration-test.

我看不到启动 tomcat 和 selenium 服务器,所以我尝试通过以下命令分别测试每个:

mvn tomcat:run
mvn selenium:start-server

所以服务器启动良好

任何想法请如何使用 Tomcat 作为 maven 构建阶段的一部分运行 selenium 测试。 提前谢谢你

【问题讨论】:

    标签: tomcat maven selenium selenium-rc


    【解决方案1】:

    从此处的原型生成示例项目:http://tomcat.apache.org/maven-plugin-2.1/archetype.html

    然后运行:mvn clean install :-) 查看名为 basic-webapp-it 的模块中的 pom 高温

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-24
      • 1970-01-01
      • 1970-01-01
      • 2013-03-20
      • 1970-01-01
      • 1970-01-01
      • 2015-08-19
      • 1970-01-01
      相关资源
      最近更新 更多