Arsenii
Arsenii

Reputation: 109

Scenario vs Scenario Outline

I need to write out a test scenario in SpecFlow with C# where:

Log In Test

I select a store from a list in Screen A
Perform tests in the store on Screen B
Go back to Store Select in Screen A
Select Second store from list 
Perform Test on store. 
Log Out

I am currently using a Scenario Outline with variable for each store off a list but that does not seem to work for me. Any ideas would be helpful?

Upvotes: 1

Views: 3607

Answers (2)

Beytullah uzun
Beytullah uzun

Reputation: 46

If you want to run tests for more then one variable then what you need is a scenario outline.
Lets say you to test a login page with various versions of invalid email and passwords, your feature file will look like this:

Feature: Name of the feature file
Scenario Outline: Brief explanation of the story
Given User clicks login
When Enters "email" and "password"
Then Error message must be seen

Examples:

| email             | password                          |  
| en email          | a password                        |

Upvotes: 0

Rob
Rob

Reputation: 27357

Your test is missing a few crucial things:

  1. You're not defining whether or not it's a scenario or scenario outline.
  2. There is no 'Given', 'When' or 'Then' step
  3. You need an Examples: block when working with a scenario outline.

Here's what your test should look like for a scenario:

Scenario: Log In Test

Given I have setup my database // Put any 'setup code' here
When I select a store from a list in Screen A // Put your 'action' here
Then Screen A should display item number 5 // Assert your 'action' does what is expected

Now, for outlines, you can run the test multiple times for different arguments. For example, the above test could be written like this:

Scenario Outline: Log In Test

Given I have setup my database
When I select a store from a list in <ScreenName>
Then <ScreenName> should display item number <ItemNumber>

Examples: 
| ScreenName | ItemNumber |
| Screen A   | 5          |
| Screen B   | 53         |
| Screen C   | 9874       |

Upvotes: 3

Related Questions