How to delete seed data in SpecFlow

Perhaps this has already been raised, perhaps a stupid question.

Anyway, I searched for SpecFlow and wondered how I can delete my seed data for this function. This seed data is shared in different scenarios. Is there an elegant way to do this? Perhaps the ability to insert an event when testRunner.OnFeatureEnd () is called?

+6
integration-testing bdd specflow acceptance-testing
source share
1 answer

You can use hooks.

Hooks are methods that execute at specific times during the execution of Gherkin functions.

At runtime, there are several hooks for different events.

In SpecFlow, you define hooks in the [Binding] classes with a 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

+8
source share

All Articles