We are applying BDD and using SpecFlow and Selenium. Acceptance criteria are specified in Gherkin.
I have a question regarding the Given clause.
An example might be...
- Given I am on the order details page
- When I submit the order
- Then I see the order summary
So for the 'Given I am on the order details page' we have to be logged in and have an order ready to submit. But how do we get to that point?
If we already have the relevant existing SpecFlow steps we can use these (via Selenium) to get to the right point - something like this...
- Given I am a registered user
- And I am on the login page
- And I log in using my registered username and password
- And I create a new order
- And I search for XYZ product
- And I add the product to the order
- And I select the order details page
- When I submit the order
- Then I see the order summary
We can even put all those steps in the step code under 'Given I am on the order details page'
However are we right to use Selenium to implement the Given? Or should we find some way to set all the relevant states/data in the session/database without going through the UI?
I suspect that there is no right or wrong here. I have to say it is working very well for us but we are always looking to improve our approach. So would be very interested to hear from anyone with real experience.
I hope Stack Overflow is the right forum for this (can't help but think it isn't - if so please don't shoot me down!)...