0

この手順を実現したい: 1-Tomcat サーバーを起動する 2-戦争を展開する 3-Selenium サーバーを起動する

だから私は自分の 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 ビルド フェーズの一部としてセレン テストを実行する方法を教えてください。前もって感謝します

4

1 に答える 1

2

ここでアーキタイプからサンプル プロジェクトを生成します: http://tomcat.apache.org/maven-plugin-2.1/archetype.html

次に実行します: mvn clean install :-) basic-webapp-it HTH というモジュールの pom を見てください。

于 2012-07-04T20:40:49.397 に答える