You should never, ever Google ‘BDD Tutorial’ or ‘Gherkin Tutorial’. Why? Once when I was teaching a BDD class I was walking around listening to the students working on an exercise, and noticed that one of the students had his phone out, and had some Gherkin on it. I looked more closely, and thought “Why does that Gherkin look familiar?”. Then I realized that it looked familiar because it was in my course material – in the section titled ‘Bad Gherkin’!
- The first Scenario has seven lines, including two ‘And’ statements after the ‘When’. This isn’t a requirement, it is a script – a Gherkin anti-pattern.
- It says ‘I enter a credit card number that is less than 16 lines long’. ‘Less than 16’ isn’t concrete – does that mean 15? 14? 0? -1? BDD requires examples to be concrete. Gojko Adzic gave BDD a better name, ‘Specification by Example’. Examples must be concrete, exact, precise.
- It talks about the interface – another Gherkin anti-pattern.
- Finally, the ‘Then’ isn’t concrete either.
Four mistakes in the first Scenario in this ‘Tutorial’!
Cucumber.io – an excellent resource!
This tutorial talks about using BDD to “write test cases” – but BDD isn’t about testing, it is about changing the way the Product Owner, Business Analyst, Developer, and QA communicate. It is about creating a ubiquitous language in which we can write requirements – not test scripts. Aslak Hellesoy wrote Cucumber, and in a blog post he wrote “If you think Cucumber is a testing tool, please read on, because you are wrong.”
“Cucumber is a testing framework….” Aslak wrote Cucumber, and he said this isn’t true.
“Cucumber is a software tool used by the testers to develop test cases…”
WOW! I am shocked! Link #6 is almost giving good advice! Almost…
- Talks about the interface (a Gherkin anti-pattern)
- Talks about sequence (a Gherkin anti-pattern)
- Says ‘write a script’
I won’t keep going, but I hope you see why you should never, ever Google ‘BDD Tutorial’! You will get really, really bad advice and training. Of the first ten links that I clicked on, only one was really reliable.
SBE/BDD is an incredibly powerful methodology for communicating requirements, developing software, and delivering automated tests, and your team will really benefit if you learn to do it well. So if you can’t Google for help, where can you go to learn Specification by Example/BDD and Gherkin – and learn it really well? Contact me and I will be glad to point you to really good resources!