I am unable to execute the below Cucumber scenario due to error in my step definition file for my when step
"User Selects <Origin>, <Destination>, <Date> and <MonthYear>".
Regular expression for Date and MonthYear have some problem. I have added my Cucumber Scenario and snippet of my step definition
Cucumber Feature:
Scenario Outline: User Searches One Way Flight
Given User is logged into the application
When User selects One way trip
And User Selects <Origin>, <Destination>, <Date> and <MonthYear>
Then Search results should be displayed.
Examples:
| Origin | Destination | Date | MonthYear |
| New York | Sydney | 20 | January 2016 |
Step Definition
@When("^User Selects \"([^\"]*)\", \"([^\"]*)\", \"(\\d+)\" and \"([\\d+]*)\"$")
public void user_selects(String origin, String destination, String date, String monthYear) {
flight.searchOneWayFlight(origin, destination, date, monthYear);
}
You need to use int
for the date and the regular expression from monthYear will not pass the month part.
@Given("^User Selects (.*?), (.*?), (\\d+) and (.*?)$")
public void userSelects(String origin, String destination, int date, String monthYear)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.