Cucumber 如何编写BDD测试用例来验证显示的UI中的列名?
我有一个以表格格式显示数据的UI。此表有9列。我需要编写BDD场景来验证所有这些列的名称。我不确定以下哪项是正确的方法。(仅包括导航到所需UI后的最后一条“Then”语句) 方法1:Cucumber 如何编写BDD测试用例来验证显示的UI中的列名?,cucumber,bdd,specflow,gherkin,Cucumber,Bdd,Specflow,Gherkin,我有一个以表格格式显示数据的UI。此表有9列。我需要编写BDD场景来验证所有这些列的名称。我不确定以下哪项是正确的方法。(仅包括导航到所需UI后的最后一条“Then”语句) 方法1: Then UI should include bill details in tabular format with "Bill ID" "Payment Type" "Facility Name" "BillAccount/Master Acc
Then UI should include bill details in tabular format with "Bill ID" "Payment Type" "Facility Name" "BillAccount/Master Account" "Supplier Name" "Statement Date" "Due Date" "Total Amount Due" and "Bill Image" columns
步骤定义:
[Then(@"UI should include bill details in tabular format with ""(.*)"" ""(.*)"" ""(.*)"" ""(.*)"" ""(.*)"" ""(.*)"" ""(.*)"" ""(.*)"" and ""(.*)"" columns")]
public void ThenUIShouldIncludeBillDetailsInTabularFormatWithAndColumns(string p0, string p1, string p2, string p3, string p4, string p5, string p6, string p7, string p8)
在这里,我可以使用字符串p0值直接获得预期的列名,并与实际值进行比较。我可以对所有9个列名执行相同的操作
方法2:
Then UI should include bill details with below columns
| col1 | col2 | | col3 | col4 | | col5 | col6 | | col7 | col8 | col9 |
| Bill ID | Payment Type | | Facility Name | BillAccount/Master Account | | Supplier Name | Statement Date | | Due Date | Total Amount Due | Bill Image |
在这种方法中,我需要知道读取作为参数值提到的列名的最佳方法。一个选项是创建一个带有9个字符串字段的自定义类,并在table.createInstance()
方法中使用相应的类
请给我推荐最好的方法。最好的方法是主观的,但更倾向于BDD测试的可读性
第二种方法最好,因为场景最容易阅读。此外,table.CompareToSet(…)
扩展方法可以方便地进行比较
无论是使用Selenium还是其他一些UI自动化框架,都需要从屏幕上刮取表值并将其分配给集合:
IEnumerable billDetails=somePageModel.GetBillDetails();
表.比较器集(billDetails);
如果项目的顺序很重要,请使用table.CompareToSet(billDetails,true)代码>过载