gpt4 book ai didi

java - cucumber 步骤定义的正则表达式错误

转载 作者:行者123 更新时间:2023-11-30 06:27:25 25 4
gpt4 key购买 nike

由于我的when步骤的步骤定义文件中存在错误,我无法执行以下Cucumber场景

"User Selects <Origin>, <Destination>, <Date> and <MonthYear>".

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

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

最佳答案

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

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

关于java - cucumber 步骤定义的正则表达式错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46886523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com