【问题标题】:Is it possible to get an array as a cell in cucumber parameters table?是否可以在黄瓜参数表中将数组作为单元格获取?
【发布时间】:2017-06-01 11:31:27
【问题描述】:

正确的写法是什么?

Scenario: Data tables
  Given I have the following order
    | vegetable |    array         | cost |
    | cucumber  |   1,2,3,4        |  10  |
    | carrot    |   empty array    |   6  |
    | potato    |   1,2,3          |   4  |

public class OrderItem {

    private String vegetable;
    private int[] array;
    private int cost;
}

@Given("^I have another order$")
public void i_have_another_order(List<OrderItem> list) throws Throwable {
    for (OrderItem orderItem : list) {
        // do something with my OrderItem..
    }
}

【问题讨论】:

    标签: java cucumber cucumber-jvm gherkin


    【解决方案1】:

    这工作正常。我已经检查过了。代码是

    public class OrderItem {
    
    private String vegetable;
    private int[] array;
    private int cost;
    
    public void set(String veg,int[] arr,int cos){
        this.vegetable=veg;
        this.array=arr;
        this.cost=cos;
    }
    
    public String getVeg(){
        return this.vegetable;
    }
    

    }

    @Given("^I have the following order$")
    public void i_have_another_order(List<OrderItem> list) throws Throwable {
        for (OrderItem orderItem : list) {
            // do something with my OrderItem..
            System.out.println(orderItem.getVeg());
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-04-15
      • 1970-01-01
      • 1970-01-01
      • 2019-09-16
      • 1970-01-01
      • 2019-04-23
      • 1970-01-01
      • 2021-01-11
      • 2021-03-26
      相关资源
      最近更新 更多