But scenarios are not suitable for reuse regardless of what form they have. They are meant as acceptance criteria - examples that explain requirements. Just like programs are not meant to be reused to construct larger programs.
I don’t believe any part of this is true.
I’d say in fact, that more than half of requirements I get every day will be stories that naturally fork from existing scenarios. When I buy golf clubs, that forks off a scenario where I’ve added them to the shopping cart. The conversations I have with stakeholders also center around this.
Building executable specifications in a language that doesn’t allow this is, in my opinion, a massive impediment to doing BDD. A library of well tested, precisely defined scenarios that are easily referred to serves as a great jumping off point for conversations about new features and new scenarios. Why not use those scenarios as a basis for new scenarios?
Anyone writing automated checks in Gherkin rather than requirements, should just stop doing that. It is pointless.
I agree, but this isn’t about that.
Either practice BDD so that the Gherkin format is useful or it makes no sense to use Gherkin. It seems most of the issues with Gherkin are the result of using it for something that it is not meant for, much like using a hammer to drive in a screw.
It is the hammer’s fault though. The lack of this feature doesn’t just make test writing harder, it makes BDD harder.
Without inheritance in Gherkin you are pushed into pushing what end up being potentially important details of the specification in the imperative step code - when you “log in as user” you simply can’t squeeze every potentially relevant detail in that step without repeating yourself a lot.
This actually causes a lot of stakeholders to lose interest in even looking at these stories. They end up being too vague to be useful to them and you lose the ability to have conversations around behavior with them. This happens a lot.
The alternative - where you have a “click” step and a “enter text in textbox” scenario, is that you have a lot of very repetitive scenarios that are extremely annoying to maintain and are potentially far too detailed for stakeholders to be interested in them.
If you do have inheritance, I find this approach works fantastically well, though. The conversation centers around the forked scenario and the parent scenario is abstracted away, the stakeholder can still refer to it if necessary - the best of all BDD worlds.
The Gherkin alternative I built, for those who are interested (it’s based upon strongly typed YAML, stories are supposed to inherit, you’re encouraged to have reusable steps like “click” and “enter text” and you can generate documentation from it which you can use to trick grumpy stakeholders into doing BDD with):
Log in as James:
given:
browser: firefox # test preconditions
steps:
- Enter text:
username: james
password: password
- Click: log in
- Should appear: dashboard
See James analytics:
based on: log in as james # test inheritance
following steps:
- Click: analytics
- Should appear: analytics dashboard
People who have a programming background often lack the testing insight.
What specific insight do you think I’m missing here?