Cucumber 如何使用不同的参数重新运行黄瓜场景大纲?

Cucumber 如何使用不同的参数重新运行黄瓜场景大纲?,cucumber,Cucumber,我有一个测试Web服务的Cumber场景大纲,类似于: Scenario Outline: Check the limit functionality When I GET "/api/activity-schedule-items.xml" with parameters {<filter>} Then the xml attribute "total-count" is "<count>" Scenarios: | filter | c

我有一个测试Web服务的Cumber场景大纲,类似于:

Scenario Outline: Check the limit functionality
  When I GET "/api/activity-schedule-items.xml" with parameters {<filter>}
  Then the xml attribute "total-count" is "<count>"

  Scenarios:
  | filter        | count |
  | 'limit' => 0  | 0     |
  | 'limit' => 2  | 2     |
  | 'limit' => 2  | 2     |
  | 'limit' => -1 | 15    |
场景大纲:检查限制功能
当我获取带有参数{}的“/api/activity schedule items.xml”时
那么xml属性“total count”是“”
情节:
|过滤器|计数|
|“限制”=>0 | 0|
|“限制”=>2 | 2|
|“限制”=>2 | 2|
|“限制”=>-1 | 15|
这很好,但是我想为我们的每个Web服务重新运行相同的场景大纲和场景。基本上,我想添加另一个场景块,如:

Scenario Outline: Check the limit functionality
  When I GET "<api>" with parameters {<filter>}
  Then the xml attribute "total-count" is "<count>"

  Scenarios:
  | filter        | count |
  | 'limit' => 0  | 0     |
  | 'limit' => 2  | 2     |
  | 'limit' => 2  | 2     |
  | 'limit' => -1 | 15    |

  Scenarios:
  | api                              |
  | /api/activity-schedule-items.xml |
  | /api/activity-schedules.xml      |
  | /api/tasks.xml                   |
场景大纲:检查限制功能
当我得到参数为{}的“”时
那么xml属性“total count”是“”
情节:
|过滤器|计数|
|“限制”=>0 | 0|
|“限制”=>2 | 2|
|“限制”=>2 | 2|
|“限制”=>-1 | 15|
情节:
|原料药|
|/api/activity-schedule-items.xml|
|/api/activity-schedules.xml|
|/api/tasks.xml|
让cucumber在两张桌子之间交叉连接

更好的方法是指定“api”表,使其应用于功能中的所有场景


有没有办法在cucumber中实现这一点?

cucumber并不真正支持场景中的“迭代”。你唯一的“本地”选择实际上是自己动手做“交叉连接”

在我工作的地方,我们有一个非常相似的情况,我们分别运行Cucumber 8次,然后汇总结果,这需要很多管道,性能非常糟糕


我最近制作了一个gem,旨在帮助解决这类问题,它非常粗糙,我个人没有在愤怒中使用它,但它可能会帮助你,看看。如果您认为它可能有用的话,我很乐意帮助您启动并运行它。

您可以使用table,但table只在行数上迭代一步,所以我将两步转换为一步。代码如下:

Scenario Outline: Check the limit functionality
  When I GET api with following parameters Then the xml attribute "total-count" is as follows
    | 'limit' => 0  | 0     | <api> |
    | 'limit' => 2  | 2     | <api> |
    | 'limit' => 2  | 2     | <api> | 
    | 'limit' => -1 | 15    | <api> |

    Examples:
     |         api                     |
     |/api/activity-schedule-items.xml |
     |/api/activity-schedules.xml      |
     |/api/tasks.xml                   |
场景大纲:检查限制功能
当我获得带有以下参数的api时,xml属性“total count”如下所示
|“限制”=>0 | 0 ||
|“限制”=>2 | 2 ||
|“限制”=>2 | 2 | |
|“限制”=>-1 | 15 ||
示例:
|原料药|
|/api/activity-schedule-items.xml|
|/api/activity-schedules.xml|
|/api/tasks.xml|
第二种是你们可能使用的传统方式

Scenario Outline: Check the limit functionality
  When I GET "<api>" with parameters {<filter>}
  Then the xml attribute "total-count" is "<count>"

    Examples:
    | filter        | count |           api                    |
    | 'limit' => 0  | 0     | /api/activity-schedule-items.xml |
    | 'limit' => 2  | 2     | /api/activity-schedule-items.xml |
    | 'limit' => 2  | 2     | /api/activity-schedule-items.xml |
    | 'limit' => -1 | 15    | /api/activity-schedule-items.xml |
    | 'limit' => 0  | 0     | /api/activity-schedules.xml      |
    | 'limit' => 2  | 2     | /api/activity-schedules.xml      |
    | 'limit' => 2  | 2     | /api/activity-schedules.xml      |
    | 'limit' => -1 | 15    | /api/activity-schedules.xml      |
    | 'limit' => 0  | 0     | /api/tasks.xml                 |
    | 'limit' => 2  | 2     | /api/tasks.xml                     |
    | 'limit' => 2  | 2     | /api/tasks.xml                     |
    | 'limit' => -1 | 15    | /api/tasks.xml                     |
场景大纲:检查限制功能
当我得到参数为{}的“”时
那么xml属性“total count”是“”
示例:
|过滤器|计数| api|
|“限制”=>0 | 0 |/api/activity-schedule-items.xml|
|“限制”=>2 | 2 |/api/activity-schedule-items.xml|
|“限制”=>2 | 2 |/api/activity-schedule-items.xml|
|“限制”=>-1 | 15 |/api/activity-schedule-items.xml|
|“限制”=>0 | 0 |/api/activity-schedules.xml|
|“限制”=>2 | 2 |/api/activity-schedules.xml|
|“限制”=>2 | 2 |/api/activity-schedules.xml|
|“限制”=>-1 | 15 |/api/activity-schedules.xml|
|“limit”=>0 | 0 |/api/tasks.xml|
|“limit”=>2 | 2 |/api/tasks.xml|
|“limit”=>2 | 2 |/api/tasks.xml|
|“limit”=>-1 | 15 |/api/tasks.xml|