开发者

How can I delete seed data in SpecFlow

This may have already been brought up, a stupid question perhaps.

Anyway, I have been looking into SpecFlow and wonderin开发者_JAVA技巧g 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜