I'm new to SpecFlow, and am setting up a number of test features/scenarios that are for authenticated users of different role types. I'm doing this via browser automation with Coypu.
So I have a Background step in the feature to set up the log in of a user in that role type.
Background:
Given I am logged in as a ...some role I'm interested in...
After each scenario in the feature, I want to log the user out again (otherwise the log in step in the Background won't work for the next scenario -- I'm keeping the same Coypu browser instance open in between tests).
I found the [AfterScenario]
annotation that I could use, but as this is scoped across all scenarios in all features (as far as I understand...) it would affect scenarios say for unauthenticated users.
I could scope the [AfterScenario]
with [Scope(Feature="Some Feature")]
I believe, but I'm anticipating having to log in/out before and after a whole number of features that I'm testing, and I'm not keen on specifying all of these with a bunch of magic strings.
So I'm wondering if there's something I can put in the Feature file, kind of the equivalent of Background but to run after each scenario in that feature. (Or alternatively, maybe the way I'm logging in/out for each scenario is not the best way to go about things?)