如何编写场景大纲以在单个参数中捕获对象列表?

How to write scenario outline to capture list of object in a single argument?

在编写 Cucumber 场景大纲测试用例时,有时我会要求我需要一个占位符来保存数据列表而不是一个。请参见下面的伪示例:

Scenario Outline: example
Given I have <input_1> 
When I choose <input_2>
Then I should receive <result_list>  //instead of a single result

Examples:
| input_1        | input_2        | result                 |
| input_1_case_1 | input_2_case_1 | result_1_case_1_part_1 |
|                |                | result_1_case_1_part_2 |
|                |                | result_1_case_1_part_3 |

在上面的示例中,我的 "result" 需要为每个 input_1 和 input_2 参数捕获一个对象列表。但是通过上面的写法,cucumber 不会将最后一条语句编译成类似这样的东西:

@Then("....")
public void i_should_receive(Datatable or list of object) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

如何编写我的黄瓜脚本来实现我想要的?

谢谢。

Scenario Outline: example
Given I have <input_1> 
When I choose <input_2>
Then I should receive <result_list>  //instead of a single result

Examples:
| input_1        | input_2        | result                                                                
| input_1_case_1 | input_2_case_1 | result_1_case_1_part_1,result_1_case_1_part_2,result_1_case_1_part_3 |

然后在你的步骤定义中

@Then("....")
public void i_should_receive(String result) throws Throwable {
    List<String> items = Arrays.asList(str.split("\s*,\s*"));
}

我已经能够通过这种方式在黄瓜示例中设置值列表:

Scenario Outline: The role already exists in the system, with the specified permissions
    Given the user admin is logged in
    And the role ADMIN with permissions <permissions> to be created
    When a call to SecurityService is performed to create system roles
    Then http status code 200 is returned
    Examples:
      |permissions                                       |
      |REGISTER_ACCOUNT,REVOKE_TOKENS,GET_ROLES,SET_ROLES|

以及具体方法:

 @And("^the role ([^\"]*) with permissions ([^\"]*) to be created$")
 public void theRoleWithPermissionsToBeCreated(String roleCode, List<String> permissions) {

对我来说,这就像一个魅力,我直接收到一个字符串列表,无需解析字符串值