Slide 1

Slide 1 text

Behaviour Driven Development mit SpecFlow 102. Treffen der .NET User Group Köln Steve Korzinetzki, lise GmbH @skorzinetzki

Slide 2

Slide 2 text

Kurzprofil der lise GmbH • Als Full-Service-Dienstleister sind wir spezialisiert auf die Erstellung von individuellen Softwaresystemen und die Planung, Konzeption, Umsetzung und den Betrieb von Intranetlösungen • Technologieunabhängig: Wir beraten neutral und wählen für unsere Kunden die unter wirtschaftlichen Aspekten passende Lösung aus • Wir entwickeln alle Lösungen mit eigenen Ressourcen an unserem Standort in Köln • Gegründet 1999 • 48 Mitarbeiter (Stand: September 2018) • Geschäftsführer: Dr. Tobias Krautkremer und Daniel Schwarz • Über 300 erfolgreich abgeschlossene Projekte in den letzten 19 Jahren • Standort: Köln-Butzweilerhof • Zertifizierung zum Microsoft Gold Partner Daten und Zahlen Unsere Kunden (Auszug) 2

Slide 3

Slide 3 text

Ankündigungen .NET User Group Köln DotNetConf - https://www.dotnetconf.net/ Startet MORGEN: 12. September 2018 Die .NET UG Köln sucht freundliche Gastgeber! 103. Treffen: Dienstag, 2. Oktober 2018 Freiwillige melden unter [email protected] 3

Slide 4

Slide 4 text

4 17. November 2018

Slide 5

Slide 5 text

Agenda • Was ist Behaviour Driven Development? • Wann wende ich BDD an? • Wie wende ich BDD an? • Was ist SpecFlow? • Wie automatisiere ich die Verifizierung mittels SpecFlow? • Hands on anhand der Bowling Kata 5

Slide 6

Slide 6 text

BDD is the missing link • Testmethoden-Namen sollen Sätze darstellen • Template für Sätze hält den Fokus • Aussagekräftiger Satz hilft bei fehlschlagendem Test • Behaviour / Verhalten ist ein nutzvolleres Wort als Test • „Bridging the communication gap“ (Gojko Adzic) • „BDD can save your agile.“ (Matt Wynne) 6

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

8 From Growing Object-Oriented Software by Nat Pryce and Steve Freeman TDD Cycle

Slide 9

Slide 9 text

ATDD / BDD Cycle 9 From Growing Object-Oriented Software by Nat Pryce and Steve Freeman

Slide 10

Slide 10 text

BDD Vorgehen • Wir binden die Fachabteilung regelmäßig ein • Wir arbeiten von außen nach innen • Wir nutzen Beispiele • Wir verwenden eine allgegenwärtig, also unmissverständliche und eindeutige Sprache (Ubiquitous Language) • Wir automatisieren die Verifizierung 10

Slide 11

Slide 11 text

BDD Missverständnisse 1. Der Kunde schert sich nicht ums Testen • Tests sind zur Verifikation, aber es geht hauptsächlich um Spezifikation 2. Der Kunde möchte keine Spezifikationen schreiben • Der Kunde soll von kognitiver Vielfalt profitieren • Er soll Informationen und konkrete Beispiele liefern 3. Man kann das gleiche ohne eine vom Fachbereich lesbare Sprache erreichen • Es geht nicht um nur ums Testen, sondern um Kommunikation und gemeinsames Verständnis (Automatisierung ist sogar optional) • Konkreter Weg um Ideen auszudrücken 11 From 3 misconceptions about BDD by Juraci Vieira and Nicholas Pufal https://www.thoughtworks.com/insights/blog/3-misconceptions-about-bdd

Slide 12

Slide 12 text

Test Automation Pyramid 12 UI Service Unit

Slide 13

Slide 13 text

Testing Iceberg business interesting technical 13 Who is interested in reading the tests?

Slide 14

Slide 14 text

Agile Requirements Journey 14 From Impact Maps and Story Maps by Christian Hassa https://de.slideshare.net/chassa/2014-0618srdimpact-mapsstorymapsen Example Mapping Reminder to have a conversation

Slide 15

Slide 15 text

Example Mapping 15 From Introducing Example Mapping by Matt Wynne https://cucumber.io/blog/2015/12/08/example-mapping-introduction

Slide 16

Slide 16 text

Example Mapping 16 Regeln (Anforderungen, Akzeptanzkriterien) Beispiele Tests verifizieren illustrieren treiben

Slide 17

Slide 17 text

Example Mapping • 3 Amigos • Erarbeitung von „Shared Understanding“ • Beispiele sind präzise, entgegen abstrakter Regeln • Beispiele treiben Testszenarien für spätere Automatisierung • Anatomie: Kontext -> Aktion -> Ergebnis 17 1. DISCOVERY

Slide 18

Slide 18 text

Example Mapping Bowling Dojo Beispiel 18

Slide 19

Slide 19 text

BDD verankert in … • … Scrum • Example Mapping als Workshop-Methode für Backlog Refinement • Akzeptanzkriterien und Beispiele aus Example Mapping Workshop ableiten • Als Teil der Definition of Ready aufnehmen • Story-Splitting anhand Rules möglich • … Kanban • Discovery als erste Spalte des Kanban-Boards • Example Mapping Workshop nach Bedarf pro Story • … verteilten Teams • Online-Tools zur gemeinsamen Bearbeitung während Example Mapping nutzen (Google Spreadsheet, Microsoft OneNote, Mindmap, …) 19

Slide 20

Slide 20 text

SpecFlow 20 From SpecFlow Home Page https://specflow.org/

Slide 21

Slide 21 text

SpecFlow Report 21

Slide 22

Slide 22 text

SpecFlow Feature File Beispiel 22 Feature: Bowling Score for Strikes When scoring a strike the next two throws count into the score of the strike Scenario: Play two rounds with strike in first round Given I score a strike When I score a 7 And I score a 2 Then the score of the first round should be 19 And the score of the second round should be 9 And the total score should be 28 2. FORMULATION

Slide 23

Slide 23 text

SpecFlow Live Coding Demo • Basis-Beispiel • Hooks • Context Injection • Frontend-Testing mit Selenium 23

Slide 24

Slide 24 text

SpecFlow Bowling Kata • Wir prüfen nicht auf (in-) valide Würfe • Wir prüfen nicht auf korrekte Anzahl von Würfen und Frames • Wir prüfen nur bei Bedarf auf Punkte eines Frames • Aufgabe 1: Feature File  20 Minuten • Aufgabe 2: Step Definitions  40 Minuten • Ziel: mindestens ein Szenario formulieren und automatisieren 24

Slide 25

Slide 25 text

SpecFlow Bowling Kata 25 ~/> git clone https://github.com/skorzinetzki/bdd-bowling-dojo.git ~/> cd bdd-bowling-dojo ~/bdd-bowling-dojo/> git checkout task1-start // do task1 ... // see sample solution via ... ~/bdd-bowling-dojo/> git checkout task1-solution // compare solutions ... ~/bdd-bowling-dojo/> git checkout task2-start // do task2 ... ~/bdd-bowling-dojo/> git checkout task2-solution // compare solutions ... 3. AUTOMATION