我的功能文件中有以下针对场景的步骤。
Given my_first_step
And my_second_step
| Themes | one | three |
| Service Windows | two | four |
And my_third_step
| Create Apps |
| Config |
我们可以在java代码中以列表的形式获取'my_third_step'的参数,如下所示
public void my_third_step(List listOfItems) {}
但是如何获取 'my_second_step' 中的参数? 我需要在java代码中获取一行作为元素数组。我怎样才能做到这一点?
最佳答案
您必须传递一个对象列表,您的对象将如下所示
public class MyObject {
private Integer themes;
private Integer service;
public Integer getThemes() {
return this.themes;
}
public void setThemes(Integer themes) {
this.themes = themes;
}
public Integer getService() {
return this.service;
}
public void setService(Integer service) {
this.service = service;
}
}
然后你可以传递一个List<MyObject>
到方法。
public void my_second_step(List<MyObject>) {
...
}
在功能文件中更改定义如下:
And my_second_step
| Themes | Service |
| one | two |
| three | four |
我希望这会有所帮助。
关于java - 如何在java代码中获取cucumber中具有多个管道的步骤的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56344866/