Hooks in SpecFlow
Hooks allow you to execute code before and after scenarios. Consider below scenario. Now before executing below scenario, you want to start the browser and after execution is over, you have to close the browser.
Below is the step definition class for above feature file. Note that we have added BeforeScenario and AfterScenario Hooks. These methods would be automatically called before (to start browser)and after scenario (to close browser).
If you want to hook BeforeScenario method to scenario tagged with say @sanity, you will have to use below syntax.
Here is the output of above example. Note that before and after method were invoked.