asleep As a customer I want to buy a coffee Scenario: Buy last coffee Given there is 1 coffee left in the machine And I have paid 1$ When I press the coffee button Then I should have a coffee served
asleep As a customer I want to buy a coffee Scenario: Buy last coffee Given there is 1 coffee left in the machine And I have paid 1$ When I press the coffee button Then I should have a coffee served Feature
asleep As a customer I want to buy a coffee Scenario: Buy last coffee Given there is 1 coffee left in the machine And I have paid 1$ When I press the coffee button Then I should have a coffee served Narrative Good practice ;-)
asleep As a customer I want to buy a coffee Scenario: Buy last coffee Given there is 1 coffee left in the machine And I have paid 1$ When I press the coffee button Then I should have a coffee served Scenario
coffee left in the machine And I have paid 1$ When I press the coffee button Then I should have a coffee served Steps Initial context Actions Expected outcomes
is 1 coffee left in the machine ? How can it be executed if it's a simple string? There's no magic :-( It's your work as a developer to give it a meaning... ... by writing step definitions
the machine/ do |n| @machine = CofeeMachine.new(n.to_i) end @Given("there is|are (\d*) coffees? left in the machine") public void givenThereAreNCoffeesLeft(String n) { this.machine = new CofeeMachine(Integer.parseInt(n)); } Regular expressions Parameters
to bootstrap any implementation. Example: ... Scenario: All steps passing means the scenario passes Given a scenario "Basic Arithmetic" with: """ When I add 4 and 5 Then the result is 9 """ And the step "I add 4 and 5" has a passing mapping And the step "the result is 9" has a passing mapping When Cucumber executes the scenario "Basic Arithmetic" Then the scenario passes ...
• Step definitions to support Seaside, Magma and other frameworks, to do *real* BDD • Cool features in Cucumber such as: o Automatic generation of step definition templates o Reporting (PDF, HTML, etc) • Integration (Browser, CI, etc) • Write translations for Gherkin (Cucumber has ~ 40) • Write documentation o Wiki, tutorials o PBE chapter
understood When I ask for questions Then no one raises his/her hand And I can go on Scenario: Questions! Given someone curious When I ask for questions Then someone asks me something And I try to answer