Upgrade to Pro — share decks privately, control downloads, hide ads and more …

BDD in Action

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

BDD in Action

Theory and Practice of Behavior Driven Development

Avatar for Vladimir Gorej

Vladimir Gorej

October 08, 2019
Tweet

Other Decks in Programming

Transcript

  1. Problems • Creating tests concerned with tech. details • Creating

    tests using TDD with insufficient value • Testing things other 2 amigos don’t care about • No common language for 3 amigos • Misunderstood specifications • Incomplete map of all system features • Not building the right software right
  2. TDD 1) Write a failing tests 2) Make the test

    pass 3) Refactor and clean 4) Repeat the step 3.) until satisfied Focus more on technical details. Avoids manual testing, allows refactors, increase maintainability and confidence of developers.
  3. BDD • Builds on TDD • Different naming in unit

    tests • Starting sentences with should • Focusing on product behavior • Crystal clear intent of the test • BDD tests as absolute minimum • Test description understood by 3 amigos
  4. BDD practices • Key goal – identify business goal and

    look for features that delivers the goal • Key activity – slicing user stories into features • Writing specification for these features • Automating the specification
  5. Example mapping 1) Write a story 2) Find acceptance criteria

    (rules) 3) Define every rule with one ore more examples 4) Find the questions about unknowns Goal Turning unknown unknown into known unknown.
  6. Nomenclature Establish common vocabulary for 3 amigos. Use mind map

    (lucidchart) to visualize it. Mind map about educational technology (c) Wikipedia
  7. Gherkin Plain English with couple syntactical rules that each of

    3 amigos can learn in couple of minutes. Each scenario demonstrates an example.
  8. BDD Tools Cucumber Will match the text in each step

    of your scenario to the appropriate test code. Other tools: JBehave, Rspec, SpecFlow
  9. Why should I care ? • Living tested documentation of

    all features • More readable tests = better quality • Focus on things that matters – Features • Reducing costs • Faster releases (no manual testing before release) • Complete 3 amigos confidence • Building the right software right
  10. How to start ? • Start trying BDD on your

    personal projects • Introduce BDD fragments to your daily work • Rewrite existing unit TDD tests into BDD style • Use expectations instead of assertions • Start using Example mapping • Test features, not implementation details • Start using cucumber by delegating to existing tests
  11. Thank you! Resources • Learning Behavior-driven Development with JavaScript by

    Enrique Amodeo • BDD in Action: Behavior-Driven Development for the whole software lifecycle by John Ferguson Smart • 1.5 year of Apiary BDD experience