This may have already been brought up, a stupid question perhaps.
Anyway, I have been looking into SpecFlow and wondering how I can delete my seed data for the feature. This seed data are shared across different scenarios. Is there an elegant way of doing this? Perhaps the ability to inject an event when testRunner.OnFeatureEnd() in invoked?
You can use hooks.
Hooks are methods that are executed at certain times during execution of Gherkin features.
There are several hooks for different events during the execution.
In SpecFlow you define hooks in your [Binding] classes with an special attribute. The following hooks are available:
[BeforeTestRun], [AfterTestRun], [BeforeFeature], [AfterFeature] [BeforeScenario], [AfterScenario], [BeforeScenarioBlock], [AfterScenarioBlock], [BeforeStep], [AfterStep]
Examples:
https://github.com/techtalk/SpecFlow-Examples/blob/master/ASP.NET-MVC/BookShop/BookShop.AcceptanceTests.Selenium/StepDefinitions/BookSteps.cs
https://github.com/techtalk/SpecFlow/blob/master/Tests/FeatureTests/BeforeAfterHooks/BeforeAfterHooksSteps.cs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With