黄瓜步骤定义的正则表达式错误

时间:2017-10-23 09:55:58

标签: java cucumber

由于我的步骤

步骤定义文件中的错误,我无法执行下面的Cucumber方案
"User Selects <Origin>, <Destination>, <Date> and <MonthYear>".

Date和MonthYear的正则表达式存在一些问题。我添加了我的Cucumber Scenario和我的步骤定义的片段

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   |

步骤定义

@When("^User Selects \"([^\"]*)\", \"([^\"]*)\", \"(\\d+)\" and \"([\\d+]*)\"$")
public void user_selects(String origin, String destination, String date, String monthYear) {
    flight.searchOneWayFlight(origin, destination, date, monthYear);
}

1 个答案:

答案 0 :(得分:1)

您需要使用int作为日期,而monthYear中的正则表达式不会传递月份部分。

@Given("^User Selects (.*?), (.*?), (\\d+) and (.*?)$")
    public void userSelects(String origin, String destination, int date, String monthYear)
相关问题