jeudi 3 mars 2016

No test results with Eclipse + Maven + Cucumber + Serenity

Okay so I have read just about every online tutorial I can find. I am trying to setup BDD test automation for a simple dating app for now. The online documentation for doing all of this in Eclipse is really poor. I have gotten it run in Eclipse and I get a test file in index.html but it is saying say there are no tests. enter image description here

I am running the tests by right clicking the project and doing 'Run As' Maven build and for 'Run Configurations' I am doing clean test verify. Here is how I am organizing my projects. enter image description here

Here is my SearchByGender.java file

 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 {}

And here is my SearchByGenderStepDefinitions.java file

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 );
    }
}

My 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) );
    }
}

My feature file

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'

And lastly here is my pom.xml.

<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU" xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/VE5zRx">
  <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>

Please help. I have to get this working for my job.

Aucun commentaire:

Enregistrer un commentaire