正确的书写方式是什么?

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..
    }
}

最佳答案

一切正常。我已经检查过了该代码是

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

关于java - 是否可以在 cucumber 参数表中将数组作为单元格获得?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44306336/

10-10 00:58