Search code examples
cucumbercucumber-java

Cucumber is not providing the method signatures for steps in the feature file


I'm trying to fill out the fields on this demo site: http://newtours.demoaut.com/mercuryregister.php

This is my feature file:

Feature: Testing Mercury Tours' register page

Background: 
    Given the user has launched their browser
    And the browser is on Mercury Tour's register page

Scenario Outline: Testing Mercury Tours' registration page via positive testing
    When the user enters the "<First Name>"
    And enters the "<Last Name>"
    And enters the "<Phone>"
    And enters the "<Email>"
    And enters the "<Address>"
    And enters the "<City>"
    And enters the "<State>"
    And enters the "<Postal Code>"
    And selects the "<Country>"
    And enters the "<User Name>"
    And enters the "<Password>"
    And enters the "<Confirm Password>"

Examples: 
  | First Name | Last Name | Phone          | Email            | Address          | City          | State | Postal Code | Country       | User Name | Password    | Confirm Password |
  | Bob        | Mayer     | 1-877-393-4448 | [email protected] | 123 Victory Lane | Beverly Hills | CA    |       90210 | United States | BobM      | 123password | 123password      |

When I run this feature file, Cucumber gives me the method signatures for the first two steps (first name & last name) and the Select draw down menu (fpr country) but not the rest:

@When("^the user enters the \"([^\"]*)\"$")
public void the_user_enters_the(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^enters the \"([^\"]*)\"$")
public void enters_the(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^selects the \"([^\"]*)\"$")
public void selects_the(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

How do I implement methods to fill other text fields like phone #, email, and address?


Solution

  • The other "missing" steps match the same pattern - ^enters the \"([^\"]*)\"$ which is the second one. If u want cucumber to emit step definition method signatures for each step consider making them unique. Change And enters the "<Phone>" to something like And enters phone details - "<Phone>".