2011-09-07 37 views
2

我有用于测试web服务类似于一个黄瓜方案概要:如何使用不同参数重新运行黄瓜场景大纲?

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 | 

的正常工作,但是我想重新运行同样的情景大纲和方案,供我们每一个web服务的。基本上,我想添加另一个Scenarios块如:

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     | 

并且让黄瓜做两个表之间的交叉连接。

更好的办法是指定“api”表格,以使其适用于该功能中的所有场景。

有没有一种方法可以在黄瓜中执行此操作?

回答

4

黄瓜并不真正支持场景的“迭代”。你唯一的'原生'选项实际上是亲自做'交叉连接'。

我在哪里工作我们有一个非常相似的情况,我们运行黄瓜8个不同的时间,然后汇总结果,这需要大量的管道和性能是可怕的。

我最近放了一块宝石,意在帮助解决这类问题,它非常粗糙,我没有亲自使用它,但它可以帮助你,看看https://github.com/jmerrifield/cuke_iterations。如果您认为它可能有用,我很乐意帮助您启动并运行它。

2

您可以使用表格,但表格仅在单行数据行上迭代,因此我将两个步骤转换为一个。代码如下:

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     | 

二是,你可能会使用

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      | 
传统方式
相关问题