2016-03-03 116 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项目来解决了这个问题。在我刚刚做一个快速入门之前。不知道为什么这解决了问题,但它确实如此。可能与插件有关。

相关问题