web-dev-qa-db-ja.com

シナリオとシナリオの概要

背景:

私は現在、Symfony2 Webページのbehatテスト(Mink/Selenium)を作成しています。たくさんの例がありますが、実際にそれらを書くことは問題ありません。ステップ定義はすでに書かれています。

ただし、例では、Scenario:を定義する場合もあれば、Scenario Outline:を定義する場合もあります。

質問:

テストを定義するこれらの2つの方法の違いは何ですか?

12
Alec

から 公式ガイド

シナリオをコピーして貼り付けて異なる値を使用すると、すぐに面倒で繰り返しになる可能性があります。

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

シナリオの概要では、プレースホルダー付きのテンプレートを使用して、これらの例をより簡潔に表現できます。

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  |

シナリオの概要の手順は、直接実行されることのないテンプレートを提供します。シナリオアウトラインは、その下の[例]セクションの各行に対して1回実行されます(最初のヘッダー行を除く)。

詳細は 書き込み機能 ガイドをご覧ください。

19
Jakub Zalas

シナリオはそれが何であるかです。

シナリオの概要では、プレースホルダーを使用してテストを高速化します。

https://github.com/cucumber/cucumber/wiki/Scenario-Outlines

0
Siim Kallari

Intellij IDEA + Cucumberこれをサポートしますが、これがすべての標準であるかどうかはわかりません。

Feature: LoginFeature
  This feature deals the login functionality of the application

Scenario: Login with correct username and password
  Given I navigate to the login page
  And I enter the following for Login
    | username | password      |
    | admin    | adminpassword |
    | admin2    | adminpassword2 |
    | admin3    | adminpassword3 |
    | admin4    | adminpassword4 |
    | admin5    | adminpassword5 |
  And I click login button
  Then I should see the userform page
0
XsrPm