将字符串添加到黄瓜功能的java列表中
问题描述:
我想添加从黄瓜功能到列表(不使用每个字符串使用.add
)的步骤中获得的字符串。将字符串添加到黄瓜功能的java列表中
例如,添加下面的字符串列表中的“字符串1”,“字符串2”,“STRING3”
而且,这将是很好,如果我能在黄瓜功能添加到文件更多的字符串,而那些会自动添加到列表中。
我试着创建一个场景大纲表,但目前没有运气。
答
请在下面找到功能文件和步骤定义。它将采用黄瓜表中的字符串列表,并将其添加到列表中而不使用.add。
Feature: Get the list of strings from table
Scenario: Get the list of strings
Given Get the strings from following table and print
|Value1|
|Value2|
|Value3|
@Given("^Get the strings from following table and print$")
public void get_the_strings_from_following_table_and_print(List<String> lstStr) throws Throwable {
for(String str:lstStr)
System.out.println(str);
}
+0
它的工作完美,我将代替“情景”方案纲要“那是为什么我的测试失败了。非常感谢! – newUser
在您的步骤中的数据表 - http://toolsqa.com/cucumber/data-tables-in-cucumber/ – Grasshopper