2016-03-03 148 views
0

好吧,我已經閱讀了幾乎所有可以找到的在線教程。我正在嘗試爲現在的簡單約會應用設置BDD測試自動化。在Eclipse中完成所有這些在線文檔非常糟糕。我已經得到了它在Eclipse中的運行,並且我在index.html中獲得了一個測試文件,但是它表示說沒有測試。 enter image description hereEclipse + Maven + Cucumber + Serenity沒有測試結果

我正在運行測試,通過右鍵單擊該項目,並執行'運行爲'Maven構建和'運行配置'我正在做乾淨的測試驗證。這是我如何組織我的項目。 enter image description here

這裏是我的SearchByGender.java文件

package sean; 

//package net.serenity_bdd.samples.etsy.features; 

import cucumber.api.CucumberOptions; 
import net.serenitybdd.cucumber.CucumberWithSerenity; 
import org.junit.runner.RunWith; 

@RunWith(CucumberWithSerenity.class) 
@CucumberOptions(features="src/test/resources/features/verify_gender.feature") 

public class SearchByGender {} 

這裏是我的SearchByGenderStepDefinitions.java文件

package sean; 

import cucumber.api.java.en.Given; 
import cucumber.api.java.en.Then; 
import cucumber.api.java.en.When; 
import net.thucydides.core.annotations.Steps; 

public class SearchByGenderStepDefinitions 
{ 
    @Steps 
    UserProfile profile; 

    @Given("I want a (.*)") 
    public void userWantsToFind() 
    { 
     profile.opens_user_profile(); 
    } 

    @When("I search for profiles containing '(.*)'") 
    public void searchByGender(String gender) 
    { 
     profile.searches_for_profiles_containing(gender); 
    } 

    @Then("I should only see profiles related to '(.*)'") 
    public void resultsForGender(String gender) 
    { 
     profile.should_see_profiles_related_to(gender); 
    } 
} 

我UserProfile.java

package sean; 

import net.thucydides.core.annotations.Step; 
import net.thucydides.core.steps.ScenarioSteps; 
import static org.assertj.core.api.Assertions.assertThat; 

public class UserProfile extends ScenarioSteps 
{ 

    private static final long serialVersionUID = 1L; 
    private String searched_gender; 
    private String status; 

    @Step 
    public void opens_user_profile() 
    { 
     status = "single"; 
    } 

    @Step 
    public void searches_for_profiles_containing(String searched_gender) 
    { 
     this.searched_gender = searched_gender; 
    } 

    @Step 
    public void should_see_profiles_related_to(String found_gender) 
    { 
     assertThat(searched_gender.equals(found_gender)); 
    } 
} 

我的特徵文件

Feature: Searching by gender 

    In order to find a girlfriend 
    As a single male 
    I want to be able to profiles containing female 

    Scenario: Should list profiles related to a specified gender 
    Given I want a girlfriend 
    When I search for profiles containing 'female' 
    Then I should only see profiles related to 'female' 

最後這裏是我的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.serenity_bdd.samples.junit</groupId> 
    <artifactId>junit-quick-start</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>Serenity JUnit Quick Start Project</name> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <serenity.version>1.0.47</serenity.version> 
     <serenity.maven.version>1.0.47</serenity.maven.version> 
     <webdriver.driver>firefox</webdriver.driver> 
    </properties> 

    <dependencies> 
     <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> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-simple</artifactId> 
      <version>1.6.1</version> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.11</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-cucumber</artifactId> 
      <version>1.0.2</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <plugins> 
      <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> 
     </plugins> 
    </build> 
</project> 

請幫忙。我必須爲我的工作做好準備。

回答

0

我通過在Eclipse中使用serenity-cucumber原型創建了一個新的Maven項目來解決了這個問題。在我剛剛做一個快速入門之前。不知道爲什麼這解決了問題,但它確實如此。可能與插件有關。

相關問題