Cucumber中如何实现Scenario Outline结合多Severity值循环执行
正确实现Cucumber Scenario Outline多参数组合循环的方式
你需要让每个ActionType分别与warnings和errors两个Severity值组合执行,也就是每个ActionType跑两轮(对应两个Severity),总共8次测试。之前的两种写法都没实现这个笛卡尔积组合,正确的写法如下:
Scenario Outline: Verify the response of actionDefinitionJson for the <Severity> When I update the action type to "<ActionType>" And I set the severity to "<Severity>" # 补充设置Severity的步骤,原场景中缺失该操作 Then verify the response of actionDefinitionJson "<Response>" And a response with 200 is returned Examples: | ActionType | Response | Severity | | Condition | null | warnings | | Condition | null | errors | | Auto-Mapping | null | warnings | | Auto-Mapping | null | errors | | Builder | expected | warnings | | Builder | expected | errors | | Editifiers | actual | warnings | | Editifiers | actual | errors |
之前写法的问题说明
- 写法1:步骤内的Data Table是该步骤的内部参数,不会与Scenario Outline的Examples表格进行组合循环。这种写法下每个ActionType只会执行一次,步骤内部处理两个Severity,并非每个ActionType对应两个Severity分别执行,不符合需求。
- 写法2:仅前两行配置了Severity值,后两行为空,导致只有4次执行,而非每个ActionType对应两个Severity的8次循环,无法满足“每个示例针对两个Severity各执行一次”的要求。
内容的提问来源于stack exchange,提问作者Thanuja
相关产品推荐
相关产品推荐

