So we are using SpecFlow (C# with Selenium WebDriver) in order to do functional testing.
I am still pretty new to using SpecFlow and Selenium. My mentor has told me that they want scenarios written in a way that only has one when and then (you set up your test, you my perform an action or two and then assert).
So I have a Scenario Outline, like so:
Scenario Outline: Outline label
Given I am on the proper page
When I apply filter "" with ""
And I click filter
Then the data should be filtered
Examples:
| filter | params |
| Date | Today |
| Name | Some Name |
| ... [20+ more] ... |
However my mentor said it would be best to instead to do something like this:
Scenario: Scenario label
Given I am on the proper page
When I apply and filter with
| filter | params |
| Date | Today |
| Name | Some Name |
| ... [20+ more] ... |
Then the data should be filtered
The point is so that the browser doesn't have to close and re-open for each of the filter tests. Instead the filter would be cleared before the next.
However, I am unsure of how best to approach this task in the best way. Since each of the filters would need to be verified before the next is done, where would the assertion be done? Within the "When I apply and filter with" and then the "Then the data should be filtered" just checks to make sure nothing failed? That seems a bit odd as the "When" case should stop as soon as one fails.
Alternatively the "When" could just store everything in the table and the "Then" would apply the filters and do the assertion -- but it then ceases to be a then as it is doing something more than asserting the expected conditions have been met.
I've been browsing around for trying to similar problems with solutions, but I haven't found anything.
I guess my basic problem here is how do I perform multiple, different yet similar, steps without having to open/close the browser for each individual example (as occurs with the Scenario Outline)? Is this even good practice or possible (without having to do multiple when/thens in a single scenario)? Is doing multiple when/thens (e.g. When ... Then ... When ... Then ...) a bad idea as well?
Thanks in advance! I've been trying to research related issues for a couple days but have found nothing that helps.