Skip to content

Simple SpecFlow Examples #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion GettingStarted/1_SimpleStarterTests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
Scenario: Add two numbers - no variables
Given I have entered the numbers 1 and 2
When I add 1 and 2 together
Then the result should be 3
Then the result should be 3

Scenario: Add two different numbers - no variables
Given I have entered the numbers 3 and 5
When I add 3 and 5 together
Then the result should be 8
40 changes: 40 additions & 0 deletions GettingStarted/1_SimpleStarterTests.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions GettingStarted/2_TestAddingNumbersWithVariables.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: TestAddingNumbersWithVariables
In order to avoid writing a lot of extra testing code
I want to be able to use variables in my SpecFlow tests

@mytag
Scenario: Add 1 and 2
Given I have the numbers 1 and 2
When I add them together
Then they should add up to 3

Scenario: Add 3 and 4
Given I have the numbers 3 and 4
When I add them together
Then they should add up to 7

Scenario: Add 101 and 1332
Given I have the numbers 101 and 1332
When I add them together
Then they should add up to 1433
220 changes: 220 additions & 0 deletions GettingStarted/2_TestAddingNumbersWithVariables.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions GettingStarted/3_TestToSeeIfOurStoreIsOpen.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Feature: Check to see if the store is open
As a potential customer
I want to know if your store is open
So I don't waste my time driving there if it isn't
Store Hours:
M-Th 8-10
Fri 8-11
Sat 10-8
Sun 10-6

@mytag
Scenario: Check if store is open at 12/11/2019 5:00PM
Given It is currently 12/11/2019 at 5:00PM
Then The store is open

Scenario: Check if store is open at 12/15/2019 11:00PM
Given It is currently 12/15/2019 at 11:00PM
Then The store is closed

Scenario: Open time edge case - store opens at 8AM
Given It is currently 12/11/2019 at 8:00AM
Then The store is open

Scenario: Close time edge case - store closes at 10:00PM
Given It is currently 12/11/2019 at 10:00PM
Then The store is closed
Comment on lines +11 to +26
Copy link
Contributor Author

@psiberknetic psiberknetic Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to use Given, When and Then for every scenario. If you don't need one, don't use them. Some tests are simple enough that you don't need to try to fit that template.

In the "Check if the store is open" example above, just the Given and Then lines provide extremely readable test scenarios.

Loading