Behavior-driven development

Jaroslav Kubicek

BDD

  • extension of TDD
  • Uses structured natural language
  • Ideas:
    • test should clearly say what software does
    • understand why test failed
    • clear overview of what to test and what NOT to test
    • emphazize user stories

BDD - structured language

 

Given a 5 by 5 game
When I toggle the cell at (3, 2)
Then the grid should look like
.....
.....
.....
..X..
.....
When I toggle the cell at (3, 1)
Then the grid should look like
.....
.....
.....
..X..
..X..
When I toggle the cell at (3, 2)
Then the grid should look like
.....
.....
.....
.....
..X..

Gherkin

Feature: Finding web page
  In order to find web page with unknown url,
  As a normal user
  I want to find it through search field


  Scenario: I want to find www.seznam.cz
    Given a search phrase www.seznam.cz
    When user navigates to google.com
    And fill in the input with phrase
    Then google.com will find seznam.cz
  • Three basic keywords - Given, When, Then
  • Features described in *.feature files

Frameworks

  • Cucumber (Ruby, Java, JS, C++)
  • JBehave (Java)
  • Behave (Python)
  • Lettuce (Python)
  • Behat (PHP)

Sources

https://dannorth.net/introducing-bdd/

https://github.com/cucumber/cucumber/wiki

https://cucumber.io/

https://en.wikipedia.org/wiki/Behavior-driven_development

BDD - nalejvarna

By Jaroslav Kubíček

BDD - nalejvarna

  • 381