Specflow: specifying multiple scripts for each function

Looking through SpecFlow documents, I try to find out if my perception is wrong. I would like to specify several completely different scenarios for each function.

For instance:

Feature: Serve coffee
    Coffee should not be served until paid for
    Coffee should not be served until the button has been pressed
    If there is no coffee left then money should be refunded

  Scenario: Buy last coffee
    Given there are 1 coffees left in the machine
    And I have deposited 1$
    When I press the coffee button
    Then I should be served a coffee

What if I want to check other scenarios in the "Serve coffee" function? For example, a scenario in which money was paid, but the button was not pressed for 5 minutes.

Does it make sense to have multiple scripts or should I use a script schema?

Thank!

+3
source share
2 answers

, . , , , . , .

TestCase NUnit, , .


gifub SpecFlow . .

:

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  |

, .

+2
Feature: Serve coffee
  Coffee should not be served until paid for
  Coffee should not be served until the button has been pressed
  If there is no coffee left then money should be refunded

Scenario: Buy last coffee
  Given there are 1 coffees left in the machine
  And I have deposited 1$
  When I press the coffee button
  Then I should be served a coffee

Scenario: Store credit until a coffee is selected
  Given I have deposited 1$
  And I have left the machine for 5 minutes
  When I press the coffee button
  Then I should be served a coffee

, , . , "", , "" ( , ) ".

, , , , , .

.

Feature: Coffee Machine Advertising video panel

Scenario: While my coffee is being served, I should be shown a 15 second advert.
+3

All Articles