Reputation: 77
I've been searching for a while now and i haven't found an answer to my question: can i run a feature file x times with the same inputs? The x should be a number that is in a config file.
Feature: SpecFlowFeature
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers on DEV environment <= Can I do this? Can DEV be a parameter?
@mytag
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
So based on the feature above, i want to be able to read from a config file a number, that will be the number of times i want to run the same feature. In other words i want to add 50 + 70 10 times. The number of times will be read from a config file. Can i do this with Specflow?
Upvotes: 2
Views: 3128
Reputation: 1939
Though I do not know how you would do this with a config file, I would advise you to create a scenario outline. For example, in your case:
Feature: SpecFlowFeature
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers on DEV environment
@mytag
Scenario Outline: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
And this concludes testrun number '<id>'
Examples:
|id|
|1 |
|2 |
|3 |
|...
Now the last step might be something void, or you could use a reporting tool to keep track of the testruns. Either way, the test is going to run as many times as the number of IDs you have in the Examples table.
You could also do:
Feature: SpecFlowFeature
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers on DEV environment
@mytag
Scenario Outline: Add two numbers
Given I have entered '<value1>' into the calculator
And I have entered '<value2>' into the calculator
When I press add
Then the result should be '<expected value>' on the screen
Examples:
|value1|value2|expected value|
|50 |70 |120 |
|50 |70 |120 |
|50 |70 |120 |
|50 |70 |120 |
|50 |70 |120 |
|50 |70 |120 |
|...
Upvotes: 3