无法在Serenity中运行测试

时间:2019-03-05 23:35:08

标签: cucumber serenity-bdd cucumber-serenity

我是自动化测试领域的新手,因此在运行Serenity测试时遇到问题。我在带有Vaadin和JPA的Maven项目中将Serenity与Cucumber和JUnit一起使用。 使用mvn验证,我得到:enter image description here

然后我尝试更改环境变量,以为可能是问题所在。enter image description here

但没有发生相同的错误消息。 这是我的pom.xml文件。

<?xml version="1.0" encoding="UTF-8"?>
<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.vaadin.demo</groupId>
<artifactId>jpacontainer-addressbook-demo</artifactId>
<version>4.0.0</version>
<packaging>war</packaging>
<name>Simple Vaadin JPAContainer example app</name>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <vaadin.version>8.0.0</vaadin.version>
    <maven.compiler.target>1.9</maven.compiler.target>
    <maven.compiler.source>1.9</maven.compiler.source>
    <serenity.version>1.0.47</serenity.version>
    <serenity.maven.version>1.0.47</serenity.maven.version>
    <webdriver.driver>chrome</webdriver.driver>
    <webdriver.chrome.driver>C:\Users\Sany\Desktop\asignaturs3\2 cuatri\GPS\chromedriver.exe</webdriver.chrome.driver>
</properties>

<organization>
    <name>Vaadin Ltd</name>
    <url>http://vaadin.com/</url>
</organization>
<inceptionYear>2009</inceptionYear>
<url>http://vaadin.com/</url>
<scm>
    <connection>scm:svn:http://dev.vaadin.com/svn/addons/JPAContainer/trunk</connection>
    <developerConnection>scm:svn:http://dev.vaadin.com/svn/addons/JPAContainer/trunk</developerConnection>
    <url>http://dev.vaadin.com/browser/addons/JPAContainer/trunk</url>
</scm>
<issueManagement>
    <system>trac</system>
    <url>http://dev.vaadin.com/</url>
</issueManagement>
<developers>
    <developer>
        <name>Petter Holmström</name>
        <id>petter</id>
        <email>petter at vaadin.com</email>
        <organization>Vaadin Ltd</organization>
        <timezone>+2</timezone>
    </developer>
    <developer>
        <name>Henri Sara</name>
        <id>hesara</id>
        <email>hesara at vaadin.com</email>
        <organization>Vaadin Ltd</organization>
        <timezone>+2</timezone>
    </developer>
</developers>

<licenses>
    <license>
        <name>Apache License version 2.0</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
        <distribution>repo</distribution>
    </license>
</licenses>

<repositories>
    <repository>
        <id>EclipseLink Repo</id>
        <url>http://www.eclipse.org/downloads/download.php?r=1&amp;nf=1&amp;file=/rt/eclipselink/maven.repo</url>
    </repository>
    <repository>
        <id>vaadin-addons</id>
        <url>http://maven.vaadin.com/vaadin-addons</url>
    </repository>
    <repository>
        <id>vaadin-snapshots</id>
        <name>Vaadin snapshot repository</name>
        <url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-compatibility-server</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.3</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin.addon</groupId>
        <artifactId>jpacontainer</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.3.160</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.2.0.Final</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.vaadin/vaadin-core -->
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-core</artifactId>
        <version>12.0.7</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>7.2.1.jre8</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-core -->
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>2.0.40</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-junit -->
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit</artifactId>
        <version>2.0.40</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-model -->
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-model</artifactId>
        <version>2.0.40</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-screenplay -->
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-screenplay</artifactId>
        <version>2.0.40</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-cucumber -->
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber</artifactId>
        <version>1.9.31</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>1.7.0</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-stats</artifactId>
        <version>2.0.40</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-screenplay-webdriver</artifactId>
        <version>2.0.40</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>

    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M3</version>
    </dependency>



</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.mycila.maven-license-plugin</groupId>
            <artifactId>maven-license-plugin</artifactId>
            <version>1.9.0</version>
            <configuration>
                <basedir>${basedir}</basedir>
                <header>${basedir}/../java-license-header.txt</header>
                <quiet>false</quiet>
                <failIfMissing>true</failIfMissing>
                <aggregate>false</aggregate>
                <useDefaultExcludes>true</useDefaultExcludes>
                <useDefaultMapping>true</useDefaultMapping>
                <encoding>UTF-8</encoding>
                <properties>
                    <year>2009-2013</year>
                </properties>
                <excludes>
                    <exclude>*/target/**</exclude>
                    <exclude>*/doc/**</exclude>
                    <exclude>**/*.xml</exclude>
                    <exclude>**/README</exclude>
                    <exclude>**/LICENSE</exclude>
                </excludes>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>format</goal>
                    </goals>
                </execution>
                <execution>
                    <id>check-headers</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
        </plugin>

        <plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat7-maven-plugin</artifactId>
          <version>2.2</version>
        </plugin>

        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>                  
            <version>2.18</version>
            <configuration>
                <includes>
                    <include>**/features/**/When*.java</include>                  
                </includes>
                <systemProperties>
                    <webdriver.driver>${webdriver.driver}</webdriver.driver> 
                    <surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
                    <surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
                </systemProperties>
            </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>
        <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-surefire-plugin</artifactId>
           <version>3.0.0-M3</version>
           <configuration>
              <testFailureIgnore>true</testFailureIgnore>
           </configuration>
        </plugin>
    </plugins>
</build>

我也尝试过:       mvn测试验证-       Dwebdriver.chrome.driver = C:\ Users \ Sany \ Desktop \ asignaturs3 \ 2       cuatri \ GPS \ chromedri       ver.exe-Dwebdriver.driver = chrome This is the message that I get

我还尝试了:mvn宁静聚合。在这里它可以构建,但是我得到了一个空报告。

这是我与“宁静”和“黄瓜”相关的所有课程:

我在听完教程后得到了这个课程,我真的不知道它是关于什么的。

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features="tests/serenity/features")
public class Runner {

}

我的步骤定义:

public class TestPrototypeStepDefinitions {

@Steps
PrototypeSteps proto;

@Managed
WebDriver driver;

@Given("I want to see my name on the page")
public void testUserWantsToSeeHisName() {
    proto.openHomePage();
}

@When("I fill the field for name with '(.*)'")
public void fillTheFieldWithName(String string) {
    proto.fillName(string);
}

@And("click Save button and click Show all inserted names button")
public void clickSaveAndShowAll() {
    proto.clickSaveBtn();
    proto.clickShowAll();
}

@Then("Then I should see my name in the list")
public void seeMyName() {

}

}

我的步骤:

public class PrototypeSteps {
HomePage hPage;

@Step
public void openHomePage() {
    hPage.open();
}

@Step
public void fillName(String name) {
    hPage.fillNameField(name);
}

@Step
public void clickSaveBtn() {
    hPage.clickSaveNameBtn();
}

@Step
public void clickShowAll() {
    hPage.clickShowAllBtn();
}
}

我的页面对象:

@DefaultUrl("https://prototipofinalha.azurewebsites.net/")  
public class HomePage extends PageObject{

@FindBy(css = "#ROOT-2521314-overlays > div.v-window.v-widget.v-has-width.v- 
has-height > div > div > div.v-window-contents > div > div > div > div > div >  div:nth-child(1) > div > div:nth-child(3) > input")
WebElement nameFiled;

@FindBy(xpath = "//*[@id=\"ROOT-2521314-overlays\"]/div[1]/div/div/div[3]/div/div/div/div/div/div[1]/div/div[5]/div")
WebElement saveBtn;

@FindBy(xpath = "//*[@id=\"ROOT-2521314-overlays\"]/div[1]/div/div/div[3]/div/div/div/div/div/div[3]/div/div/div/div[3]/div")
WebElement showAllBtn;

public HomePage fillNameField(String name) {
    this.nameFiled.sendKeys(name);
    return this;
}

public HomePage clickSaveNameBtn() {
    this.saveBtn.click();
    return this;
}

public HomePage clickShowAllBtn() {
    this.showAllBtn.click();
    return this;
}

}

最后是我的小黄瓜场景:

 Feature: Name

 As a test scenario user
 I want to be able to save my name
 In order to have my name saved in the programme

 Scenario: Should save the given name and list all inserted
 Given I want to see my name on the page
 When I fill the field for name with 'name' 
 And click Save button and click Show all inserted names button 

我知道有很多代码和文本,但是我不确定问题可能出在哪里或我做错了什么。 感谢您的宝贵时间。

0 个答案:

没有答案