1

嗨,这是我所拥有的:

Scenario Outline: Seatching for stuff
Given that the following simple things exists:
  | id  | title                 | description                           | temp      |
  | 1   | First title           | First description                     | low       |
  | 2   | Second title          | Second description with öl            | Medium    |
  | 3   | Third title           | Third description                     | High      |
  | 11  | A title with number 2 | can searching numbers find this 2     | Exreme    |
When I search for <criteria> 
Then I should get <result>
And I should not get <excluded>

Examples
|criteria|results   | excluded  |
| 1      | 1        | 2,3,11    |
| 11     | 11       | 1,2,3     |
| title  | 1,2,3    | 11        |
| öl     | 2        | 1,3,11    |
| Fir*   | 1        | 2,3,11    |
| third  | 3        | 1,2,11    |
| High   | 3        | 1,2,11    |

如您所见,我正在尝试使用 cucumber 和场景大纲结构测试 Web 应用程序的搜索字段,以测试多个搜索条件。我不确定如何处理我将获得的输入并在我的步骤中排除。

也许这根本不起作用?有解决方法吗?

4

1 回答 1

3

你在做什么没有错。Cucumber 只会把它当作一个字符串。它实际上是逗号分隔的值这一事实对 Cucumber 没有任何意义。

您的步骤定义仍将如下所示:

Then /^I should not get ([^"]*)$/ do |excluded|
    # excluded will be a string, "2,3,11"
    values = excluded.split(",")

    # Do whatever you want with the values
end
于 2012-06-19T18:08:06.830 回答