I am looking for a way to implement inheritance in specflow features. For e.g a base features class which has common scenarios which have to be tested.
3-4 derived features classes which inhert all the scenarios in the base class and add some of their own. Similarly the Binding class will also follow a inheritance structure. This is needed to test an ASP.NET MVC application which has a base controller (scenarios in base features class) and 4-5 implementations.
I can copy the features file for each derived controller class but this would lead to considerable duplication.
Is this possible in specflow, Or am I going down the wrong route? Please help. thanks,
I’m not 100% sure if this is the right path to take (read as, I’ve never needed to do anything like this). For me any inheritance and re-use comes in the Step Definitions (or Binding) classes. But even so…
I don’t know if you can simply do this using the tools available in SpecFlow – but you have the following option so far as I can see (this isn’t a tested theory… I might test it later – but I figured this might offer you an idea…)
Hopefully this helps a little.
EDIT:
Okay I’ve tested this theory… It would work as I’ve described above. I just created a new project with associated test/spec project, and did the above in the test/spec project. The test runner ran the base feature, and then ran the specific/implementation feature… which included the base feature again.
Have a go – it takes less than 5 minutes to knock up what I’ve suggested, and see if the result fits your requirement.