Wednesday, August 1, 2018

Parameterization in Cucumber - Quotation

When feature step has been glued to step definition, there are several ways to pass parameters to step definition from features.

The first way is using quotation marks ("") in features.

  Feature: Sign In

  Scenario: Login Failure
    Given User is on Home Page
    And Sign In link is displayed
    When User clicks the Sign In link
    And User enters wrong "username" and "password"
    Then User should see the failed message


So the "username" and "password" will be passed to step definition method as parameters.

@When("User enters wrong \"(.*)\" and \"(.*)\"")
public void user_enters_wrong_username_and_password(String username, String password) {
...
}

No comments:

Post a Comment