Knowledge check
Ten questions on the decisions this course made and why. Each answer explains the reasoning once you check.
1. A manager asks the team to "do BDD" by installing Cucumber and converting the existing Selenium tests to feature files. What is the most important thing missing from that plan?
BDD is a collaboration practice; Cucumber only automates its output. Converting existing tests adds a layer of Gherkin without the conversations that make it valuable.
2. During example mapping, one rule card has eight examples under it and three red cards beside it. What does that suggest?
Many examples signal complexity, and red cards signal unknowns. Both are reasons to slow down before building, which is exactly what the map is for.
3. Which step is written declaratively?
The declarative step names the behaviour and would stay true for a mobile app or an API. The others describe one particular UI and break when it changes.
4. A new Cucumber-JVM 8 project fails at start-up with "Cucumber needs a JSON library to write reports". Which dependency is missing?
Jackson became opt-in in Cucumber-JVM 8, and reports that serialise Cucumber's messages need it. The other modules have nothing to do with JSON.
5. A scenario says Then the sign-in is rejected because the pasword is invalid (typo). The step definition uses a {field} parameter type matching username|password. What happens?
A parameter type's regular expression decides what matches. "pasword" matches neither alternative, so no step definition matches and Cucumber reports an undefined step with a snippet.
6. With cucumber-picocontainer, SignInSteps and Hooks both take a Browser in their constructor. How many Browser objects exist during one scenario?
PicoContainer creates each requested class once per scenario and injects the same instance everywhere, then discards it. That is what makes sharing within a scenario and isolation between scenarios work together.
7. A feature's Background has seven steps, and two of the five scenarios do not need three of them. What should you do?
A Background is read as true for every scenario. Steps that some scenarios do not need mislead the reader and slow every scenario down.
8. In Cucumber-JS, why are step definitions written as async function () {} rather than arrow functions?
The World holds the page and browser for the scenario and is bound to this. An arrow function keeps the surrounding this, which is undefined in an ES module.
9. You want the same scenarios on Chrome and Firefox on TestingBot, grouped together in the dashboard. What is the cleanest approach?
The browser is a property of the run, not of the behaviour. One invocation per browser keeps the feature files clean, and a shared build name groups the sessions.
10. A .NET team asks whether to start a new BDD project on SpecFlow. What do you tell them?
SpecFlow still installs from NuGet but receives no fixes. Reqnroll continues the same model and supports Cucumber expressions. Behave is a Python tool.
Where to go next#
You can now run discovery sessions, write Gherkin that the business can read, and automate it with Cucumber-JVM, Cucumber-JS, Behave or Reqnroll on a cloud grid with reports and CI. Good next steps:
- The Page Object Model course for the layer between step definitions and the browser.
- The flaky tests course when scenarios start failing intermittently.
- The cross-browser testing course to decide which browsers your scenarios should run on.
- The TestingBot docs for TestNG and Cucumber, Behave and Reqnroll as a reference for capabilities and options.
When your suite runs green on TestingBot, the certification is one exam away.
You finished BDD with Cucumber: Gherkin to CI
Put what you learned into practice. Run your tests on 6100+ real browsers and physical iOS and Android devices.