Run specific scenario before other scenario
Very often I have to run specific complex scenario before running other scenario.
Example:
Scenario 1: User goes to the market
Scenario 2: User buys milk (I want to recall to the first scenario before this)
Scenario 3: User buys bread (I want to recall again to the first scenario before this)
Scenario 4: Unsatisfied user returns product (I want to recall again to the first scenario before this) and so on and so on...
Presently, I have to copy all steps from Scenario 1 in any new .feature that I want to automate which makes the full process very complex and requires hard work especially if the Scenario 1 has change requests. Then I will need to search all copied steps in all other features and update them.
p.s. I have created this as feature request because I believe there is no support for this presently. If I am mistaken or there is a workaround I am open for any advice :)
-
Have you thought about using hooks/tags to run setup.
for example you could have
@Launch_Market
Scenario: User buys milkthen in your steps have a binding scoped to the tag @Launch_Market that calls the steps to go to market before the scenario is executed
1 -
Ilija Ivanovski I moved the thread to the discussion forum because it is out of the hands of SpecFlow. The unit test runner decides in which order the scenarios are executed. Some of them have functionality for it, some not or go the way to execute scenarios in a random order, to force the users to not have scenarios/tests that depend on each other. Because this is seen as bad practice.
Did you saw the Given-When-Then with Style entry about this topic?
Challenge: https://specflow.org/blog/how-to-call-one-scenario-from-another-givenwhenthenwithstyle/
Solution: https://specflow.org/blog/solving-how-to-call-one-scenario-from-another-givenwhenthenwithstyle/
0 -
Hi Andreas yes I have read that thank you for sharing.
0
Please sign in to leave a comment.
Comments
3 comments