如何解决质量保证 |在数据驱动测试中,直接在 StepDef 中检索 csv 数据行
在我使用 QAF Gerkin 的设置中,我在测试数据文件中有 80 多个数据列,这很难使用“
例如: 特征文件:
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"))'}
步骤定义:
QAFTestStep(description="Test Data Retrive")/**/
public void testDataRetrive(){
System.out.println("============>>>>>>>==========");
System.out.println(getBundle().getString("customer_name"));
System.out.println("============<<<<<<<>>>>>>>==========");
}
注意:如果我在步骤中直接提到列名,我可以检索数据。
解决方法
您的步骤需要接受调用时需要传递的参数和值。为了从数据提供者传递记录/条目,您可以使用 args[0]
引用作为值。
参考下面的例子:
@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"))'}
参考answer类似的问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。