[英]QAF | In Data driven testing, retrieving csv data row directly inside StepDef
In my setup using QAF Gerkin, I have an 80+ data column in the test data file which is very difficult to pass all the columns in steps using "<data_column>".在我使用 QAF Gerkin 的设置中,我在测试数据文件中有 80 多个数据列,很难使用“<data_column>”分步传递所有列。 I would like to retrieve all the column data directly in my StepDef according to data-driven iteration.我想根据数据驱动的迭代直接在我的 StepDef 中检索所有列数据。 I have tried using getBundle().getString("column_name"), but it is not working.我曾尝试使用 getBundle().getString("column_name"),但它不起作用。
Eg: Feature File:例如:功能文件:
Scenario outline: UI-34_Customer Creation
And I request api "get.sample.call"
And I assert api response status is "200"
And Test Data Retrive
Examples: {"datafile": "data/scenarios/1622630669181.csv", "filter": '(_status==true) && (_id.equalsIgnoreCase("UI-34"))'}
StepDef:步骤定义:
QAFTestStep(description="Test Data Retrive")/**/
public void testDataRetrive(){
System.out.println("============>>>>>>>==========");
System.out.println(getBundle().getString("customer_name"));
System.out.println("============<<<<<<<>>>>>>>==========");
}
Note: I'm able to retrive the data, if I mention the column name directly in Step.注意:如果我在 Step 中直接提及列名,我可以检索数据。
Your step need to accept argument and value need to passed when called.您的步骤需要接受参数,并且在调用时需要传递值。 In order to pass record/entry from data-provider you can use args[0]
reference as value.为了从数据提供者传递记录/条目,您可以使用args[0]
引用作为值。
Refer example below:请参考以下示例:
@QAFTestStep(description="Test Data Retrive {testdata}")
public void testDataRetrive(Map<String, Object> data){
System.out.println("============>>>>>>>==========");
System.out.println(data.get("customer_name"));
System.out.println("============<<<<<<<>>>>>>>==========");
}
Scenario outline: UI-34_Customer Creation
And I request api "get.sample.call"
And I assert api response status is "200"
And Test Data Retrive "${args[0]}"
Examples: {"datafile": "data/scenarios/1622630669181.csv", "filter": '(_status==true) && (_id.equalsIgnoreCase("UI-34"))'}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.