Closed SDETRK closed 6 years ago
So far I don't see a good use case for these. Others mentioned couple of technical reasons only, which could be implemented differently as well (e.g. before can be done in setup, after can be done in teardown). If you have a use case in mind, please let me know.
However, there is a plan to support Scenario Background, which is somewhat equal to "before scenario". That natively fits in the concept of Gherkin.
It is basically for setups and preparations before running tests or cleanups after running a test. For example, getting the url from a config file or connection strings,etc. Can you please provide example of how we can do the setup and teardown?
You can refer to Xunit documentation for that. Since this framework is built on top of Xunit framework, you can use all techniques applicable to Xunit. For instance, in Xunit, setup (code that runs before every scenario) should be written inside test class constructor. Teardown (after every scenario) should be inside Dispose. Here is a documentation which will help understand how you do such common things in Xunit: https://xunit.github.io/docs/comparisons.html
Yeah using xunit techniques work. Thank you
Specflow supports predefined hooks that can be used to perform additional automatic logic on specific events, such as before/after executing a scenario. For example: [BeforeTestRun], [BeforeFeature], [BeforeScenario], etc. Is there a plan to support this as well?