Maven构建成功,没有运行测试

时间:2015-06-17 11:16:15

标签: xml eclipse maven selenium-webdriver

我最近在Eclipse中设置新的maven项目时遇到了问题。它们运行时我遵循与先前项目相同的模式,但偶尔我得到一个没有测试运行的成功构建。我不知道为什么。

这是我的测试文件:

    package net.greendeal.test;

    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.openqa.selenium.WebDriver;


    import net.greendeal.test.steps.GreenDealSteps;
    import net.serenitybdd.junit.runners.SerenityRunner;
    import net.thucydides.core.annotations.Managed;

    import net.thucydides.core.annotations.Steps;
    import net.thucydides.core.annotations.Title;

    @RunWith(SerenityRunner.class)
    public class GreenDealTest {

    @Managed
    WebDriver driver;

    @Steps
    GreenDealSteps steps;

    @Test
    @Title("Open GD Web and enter in user data")
    public void testgdweb(){
        steps.gotogdweb();

        steps.enterUsername("unittest");

        steps.enterPassword("Password1");

        steps.loginbutton();

        steps.loginValidation("< June 2015 >");
}
}

这是我的步骤文件:

package net.greendeal.test.steps;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import net.serenitybdd.core.annotations.findby.By;
import net.thucydides.core.annotations.Step;
import net.thucydides.core.steps.ScenarioSteps;
import static org.junit.Assert.*;

@SuppressWarnings("serial")
public class GreenDealSteps extends ScenarioSteps {

    @Step ("TimeOut")
    public void TimeOut(){
    getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    }


/*  private static final long timeOut = 5;*/

    @Step ("Go To http://gdweb-uat.stromamembers.net/Members/UserManagement")
    public void gotoUserManagement() {
    getDriver().get("http://gdweb-uat.stromamembers.net/Members/UserManagement");
    }

    @Step ("Go to http://gdweb-uat.stromamembers.net/")
    public void gotogdweb() {
    getDriver().get("http://gdweb-uat.stromamembers.net//");
    }


    @Step ("Enter username")
    public void enterUsername(String s){
    getDriver().findElement(By.id("Login1_UserName")).sendKeys(s);
    }

    @Step ("Enter password")
    public void enterPassword(String s){
    getDriver().findElement(By.id("Login1_Password")).sendKeys(s);
    }

    @Step ("Click login button")
    public void loginbutton(){
    getDriver().findElement(By.id("Login1_LoginButton")).click();

    }


    @Step ("Login Validation to verify that the user has logged in and can see May 2015 in the calendar")
    public void loginValidation(String s){
    String actualValue = getDriver().findElement(By.className("calendartitle")).getText();
    assertEquals(s, actualValue);

    }


}

这是我的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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>net.GreenDeal</groupId>
  <artifactId>GreenDealTests</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Green Deal Tests</name>
  <description>Green Deal Tests Automation</description>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <junit.version>4.12</junit.version>
        <serenity.version>1.0.47</serenity.version>
        <serenity.maven.version>1.0.47</serenity.maven.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.45.0</version>
        </dependency>


        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>core</artifactId>
            <version>${serenity.version}</version>
        </dependency>

        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-junit</artifactId>
            <version>${serenity.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.18.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <includes>
                        <include>""/"Test.java</include>
                        <include>""/When".java</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <fork>true</fork>
                    <executable>C:\Program Files\Java\jdk1.8.0_45\bin\javac.exe</executable>
                </configuration>
            </plugin>

            <plugin>
                <groupId>net.serenity-bdd.maven.plugins</groupId>
                <artifactId>serenity-maven-plugin</artifactId>
                <version>${serenity.maven.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>net.serenity-bdd</groupId>
                        <artifactId>core</artifactId>
                        <version>${serenity.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>serenity-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

</project>   

1 个答案:

答案 0 :(得分:-1)

所以我发现我的问题是我将所有文件都放在main而不是test java文件夹中。问题解决了。