是否有可能将数组作为黄瓜参数表中的单元格?

时间:2017-06-01 11:31:28

标签: java cucumber cucumber-jvm gherkin

目前的写作方式是什么?

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

1 个答案:

答案 0 :(得分:2)

这很好用。我检查了一下。代码是

protected void onPause(){
    super.onPause();
    SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.putInt(FUELBAR, fuelBar.getProgress());
    editor.commit();

}

public void onResume(){
    super.onResume(); 
    fuelBar = (ProgressBar) findViewById(R.id.fuelProgressBar);
    SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
    incFuel = sharedPref.getInt(FUELBAR, 0);
    fuelBar.setProgress(incFuel);
}

public void onStop(){
    super.onStop();
}

}

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