2017-06-13 53 views
-1

我想添加從黃瓜功能到列表(不使用每個字符串使用.add)的步驟中獲得的字符串。將字符串添加到黃瓜功能的java列表中

例如,添加下面的字符串列表中的「字符串1」,「字符串2」,「STRING3」

而且,這將是很好,如果我能在黃瓜功能添加到文件更多的字符串,而那些會自動添加到列表中。

我試着創建一個場景大綱表,但目前沒有運氣。

+0

在您的步驟中的數據表 - http://toolsqa.com/cucumber/data-tables-in-cucumber/ – Grasshopper

回答

1

請在下面找到功能文件和步驟定義。它將採用黃瓜表中的字符串列表,並將其添加到列表中而不使用.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

相關問題