java cucumber pass date as string 错误

java cucumber pass date as string error

Java - 黄瓜

我是编写黄瓜测试的新手,在给定的方法签名上遇到错误,有人可以帮忙吗?

以下是我的功能文件条目

@txn
Feature: ORP

  Scenario Outline: Save a ORP
    Given when i pass start date <start date> and end date <end date>
    When the user saves a ORP
    Then the PROP is saved
    Examples:
    | start date  | end date  |
    | 1-1-2016    | 1-1-2017  |

和步骤文件作为以下签名以获得给定的开始和结束日期

@Given ("^when i pass start date (.+) and end date (.+)$")
public void processOPR(String, start, String end){...}

当我 运行 我的测试出现以下错误

Exception

    @Given("^when i pass start date (\d+)-(\d+)-(\d+) and end date (\d+)-(\d+)-(\d+)$")
public void when_i_pass_start_date_and_end_date(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();

我想在一个变量而不是 3 个不同的变量中传递日期“1/1/2016”。

找到解决方案如下

@Given ("^when i pass start date (.+) and end date (.+)$")
public void processOPR(@Format("dd-MM-yyyy")Date start, @Format("dd-MM-yyyy") Date end){...}