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

Behavior Driven Development 101

Behavior Driven Development 101

Einführung in den methodischen Ansatz von Behavior Driven Development. Code-Beispiele von SpecFlow: https://github.com/SpecFlowOSS/SpecFlow-Examples

Steve Korzinetzki

August 10, 2022
Tweet

More Decks by Steve Korzinetzki

Other Decks in Technology

Transcript

  1. Über mich Steve Korzinetzki Organisationsmitglied der Softwerkskammer Köln Suite Delivery

    Consultant @ empower GmbH Twitter: @skorzinetzki XING: Steve Korzinetzki E-Mail: [email protected]
  2. „BDD practitioners explore, discover, define, then drive out the desired

    behaviour of software using conversation, concrete examples, and automated tests.“ From Cucumber for Java Book by Seb Rose, Matt Wynne and Aslak Hellesøy
  3. „BDD practitioners explore, discover, define, then drive out the desired

    behaviour of software using conversation, concrete examples, and automated tests.“ From Cucumber for Java Book by Seb Rose, Matt Wynne and Aslak Hellesøy 1. Discovery
  4. „BDD practitioners explore, discover, define, then drive out the desired

    behaviour of software using conversation, concrete examples, and automated tests.“ From Cucumber for Java Book by Seb Rose, Matt Wynne and Aslak Hellesøy 1. Discovery 2. Formulation
  5. „BDD practitioners explore, discover, define, then drive out the desired

    behaviour of software using conversation, concrete examples, and automated tests.“ From Cucumber for Java Book by Seb Rose, Matt Wynne and Aslak Hellesøy 1. Discovery 2. Formulation 3. Automation
  6. Die drei Phasen von BDD See https://cucumber.io/docs/bdd/ Discovery: What it

    could do Formulation: What it should do Automation: What it actually does
  7. Example Mapping Story Mapping Impact Mapping Die Reise agiler Anforderungen

    Goals Impacts Deliverables User Activities Epics User Stories Acceptance Criteria Examples Code Warum? Outcomes Wie? Spezifikation früher später 󰢧 User Stories: Erinnerung daran, eine Konversation zu haben
  8. Regeln und Beispiele Regeln Beispiele Tests Beispiele illustrieren Regeln (Anforderungen,

    Akzeptanzkriterien) (Szenarien) Beispiele steuern Tests Tests verifizieren Regeln
  9. Example Mapping in a Nutshell From https://cucumber.io/blog/bdd/example-mapping-introduction/ 3 Amigos (biz,

    dev, qa) keine Gherkin- Syntax nur WAS, nicht WIE Thumb Voting Beispiele nicht immer erforderlich 25 Minuten rot überwiegt -> DoR nicht erfüllt viel blau -> Story splitten
  10. Gherkin Syntax Feature einleitender Prosatext zur Beschreibung der Funktionalität. Background

    ermöglicht das Aufsetzen eines Ausgangszustands für mehrere Scenarios. Scenario beschreibt einen konkreten Testfall (in Prosatext). Scenario Outlines beschreibt ein Scenario, das mit unterschiedlichen Examples ausgeführt wird. Given erzeugt einen Ausgangszustand, die Grundannahme (Arrange). When ist die konkrete Stimulierung des Systems under Test (Act). Then verifiziert das Ergebnis aus der When Stimulierung (Assert). Examples beschreibt die Test Cases für ein Scenario Outline.
  11. Ein Beispiel in Gherkin Syntax Feature: pizza-change-delivery-address As a customer

    I want to change the delivery address after ordering a pizza when not picked up yet so I can recover from delivering to the wrong address Scenario: Pizza waiting for pickup, changing delivery address should be accepted Given "Peter" orders some pizza to "home" address And the pizza is waiting for pickup When the customer wants to change the delivery address to "work" Then the system should accept the change Scenario: Pizza already picked up, changing delivery address should be denied Given "Tim" orders some pizza to "home" address And the pizza is picked up by the driver When the customer wants to change the delivery address to "work" Then the system should deny the change with message "Already picked up"
  12. Test Automation Pyramid aka Testing Iceberg Business betroffen / BDD

    technisch / TDD Wer hat Interesse daran, Spezifikation zu lesen?
  13. „Allow an application to equally be driven by users, programs,

    automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases.“ Alistair Cockburn
  14. Empfehlungen, Vertiefungen Softwerkskammer Köln 12.09.22: Revisionssicher Testen mit Cucumber &

    Testcontainers Devcouch Podcast: Episode Faszination Speckstein. Specflow muss versteckt sein. (09.02.2020) BDD Books: Discovery, Formulation, Automation https://bddbooks.com/ Cucumber: BDD Automatisierung https://cucumber.io/ Cukedoktor: Tool für Reporting von Cucumber Tests https://github.com/rmpestano/cukedoctor