场景与场景大纲

Ale*_*lec 8 php behat

背景:

我正在为Symfony2网页编写behat测试(Mink/Selenium).我有很多例子,实际上写它们应该没问题.已经编写了步骤定义.

但是,在示例中,它们有时会定义a Scenario:和某些时间aScenario Outline:

题:

这两种定义测试的方法有什么区别?

Jak*_*las 19

官方指南:

复制和粘贴方案以使用不同的值可能很快变得乏味和重复:

Scenario: Eat 5 out of 12
  Given there are 12 cucumbers
  When I eat 5 cucumbers
  Then I should have 7 cucumbers

Scenario: Eat 5 out of 20
  Given there are 20 cucumbers
  When I eat 5 cucumbers
  Then I should have 15 cucumbers
Run Code Online (Sandbox Code Playgroud)

场景大纲允许我们通过使用带占位符的模板来更简洁地表达这些示例

Scenario Outline: Eating
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Examples:
    | start | eat | left |
    |  12   |  5  |  7   |
    |  20   |  5  |  15  |
Run Code Online (Sandbox Code Playgroud)

Scenario Outline步骤提供了一个永远不会直接运行的模板.对于其下方的"示例"部分中的每一行,都会运行一次"场景大纲"(第一个标题行除外).

更多在写作功能指南.