Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在maven项目的Cumber测试中运行GlassFish和Selenium?_Maven_Netbeans_Selenium_Glassfish_Cucumber - Fatal编程技术网

如何在maven项目的Cumber测试中运行GlassFish和Selenium?

如何在maven项目的Cumber测试中运行GlassFish和Selenium?,maven,netbeans,selenium,glassfish,cucumber,Maven,Netbeans,Selenium,Glassfish,Cucumber,如何在POM文件中映射所有内容?POM: <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">

如何在POM文件中映射所有内容?

POM:

 <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>pl.cucumber.test</groupId>
            <artifactId>cucumber-with-glassfish</artifactId>
            <version>1.0.0</version>

            <properties>
                <jdk.version>1.7</jdk.version>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <cucumber.version>1.1.3</cucumber.version>
                <junit.version>4.11</junit.version>
                <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
                <maven-surefire-plugin.version>2.14.1</maven-surefire-plugin.version>
                <cargo-maven2-plugin.version>1.4.0</cargo-maven2-plugin.version>
                <glasfish.port>8080</glasfish.port>
                <glasfish.home>${project.build.directory}/glasfish</glasfish.home>
                <selenium.version>2.32.0</selenium.version>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>info.cukes</groupId>
                    <artifactId>cucumber-java</artifactId>
                    <version>${cucumber.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>info.cukes</groupId>
                    <artifactId>cucumber-junit</artifactId>
                    <version>${cucumber.version}</version>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>${junit.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-java</artifactId>
                    <scope>test</scope>
                    <version>${selenium.version}</version>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${maven-compiler-plugin.version}</version>
                        <configuration>
                            <source>${jdk.version}</source>
                            <target>${jdk.version}</target>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>${maven-surefire-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>integration-test</id>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <version>${cargo-maven2-plugin.version}</version>
                        <configuration>
                            <container>
                                <containerId>glassfish3x</containerId>
                                <zipUrlInstaller>
                                    <url>http://dlc.sun.com.edgesuite.net/glassfish/3.1.2.2/release/glassfish-3.1.2.2.zip</url>
                                    <downloadDir>${basedir}/downloads</downloadDir>
                                </zipUrlInstaller>
                                <output>${project.build.directory}/container.log</output>
                                <append>false</append>
                                <log>${project.build.directory}/cargo.log</log>
                                <systemProperties>
                                    <mySystemProperty>value</mySystemProperty>
                                </systemProperties>
                            </container>
                            <configuration>
                                <home>${glasfish.home}</home>
                                <properties>
                                    <cargo.servlet.port>${glasfish.port}</cargo.servlet.port>
                                    <cargo.logging>medium</cargo.logging>
                                </properties>
                            </configuration>
                            <!--
                            <deployables>
                                 <deployable>
                                                      <groupId>pl.cucumber.warproject</groupId>
                                                      <artifactId>warproject</artifactId>
                                                      <version>1.0</version>
                          <type>war</type>
                                   <properties>
                                     <context>mycontext</context>
                                  </properties>
                                </deployable>
                            </deployables>
                             -->
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </project>
测试标题页:

public class TestTitlePages {

    private WebDriver driver;

    @Given("^Connect to the given address$")
    public void a_User_has_no_money_in_their_current_account() {
        // Create a new instance of the html unit driver
        driver = new HtmlUnitDriver();

    }

    @When("^Address is (.*)$")
    public void connectTo(String address) {
        //Navigate to desired web page
        driver.get(address);
    }

    @Then("^Title is (.*)$")
    public void titleIs(String expectedTitle) {
        //get the title of the page
        String actualTitle = driver.getTitle();
        // verify title
        Assert.assertEquals(actualTitle,expectedTitle);
    }

}
测试功能:

Feature: Check the title

Scenario: Connect to the given address and check the title
Given Connect to the given address
When Address is http://www.google.com
Then Title is Google
项目结构:

src/test/
    java/
        pl/cucumber/test/
            RunIT.java
            TestTitlePages.java
    resources
        pl/cucumber/test
            test.feature
调用
mvn验证

src/test/
    java/
        pl/cucumber/test/
            RunIT.java
            TestTitlePages.java
    resources
        pl/cucumber/test
            test.feature