Slide 1

Slide 1 text

Driving Behaviour with Cucumber Zach Dennis Mutually Human Software www.mutuallyhuman.com

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

later... ...still joyful

Slide 4

Slide 4 text

a framework for writing and executing high level descriptions of your software’s behavior

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Cucumber is not a low level testing/specification framework.

Slide 8

Slide 8 text

Cucumber is a BDD tool

Slide 9

Slide 9 text

BDD was reframing of TDD

Slide 10

Slide 10 text

It has evolved into its own

Slide 11

Slide 11 text

Dan North’s 3 Principles of BDD

Slide 12

Slide 12 text

1. Enough is enough

Slide 13

Slide 13 text

2. Deliver stakeholder value

Slide 14

Slide 14 text

3. It’s all behaviour

Slide 15

Slide 15 text

how

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

I want ...

Slide 18

Slide 18 text

ok, why?

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

In order to reduce time managing contacts users should be able to search for contacts within their account

Slide 21

Slide 21 text

In order to reduce time managing contacts users should be able to search for contacts within their account value

Slide 22

Slide 22 text

In order to reduce time managing contacts users should be able to search for contacts within their account role

Slide 23

Slide 23 text

In order to reduce time managing contacts users should be able to search for contacts within their account behaviour

Slide 24

Slide 24 text

In order to reduce time managing contacts users should be able to search for contacts within their account searching contacts

Slide 25

Slide 25 text

searching contacts details

Slide 26

Slide 26 text

searching contacts details Searching by name

Slide 27

Slide 27 text

searching contacts details Searching by name Searching by partial name

Slide 28

Slide 28 text

searching contacts details Searching by name Searching by partial name Searching for non-existent person ...

Slide 29

Slide 29 text

searching contacts details Searching by partial name Given John Smith exists And I’ve logged in as a user When I search for Jo Then I should see John Smith is found

Slide 30

Slide 30 text

Organizing

Slide 31

Slide 31 text

Project Management Tools

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Code Stories Acceptance Criteria Today

Slide 34

Slide 34 text

Code Stories Acceptance Criteria Near Distant Future

Slide 35

Slide 35 text

Code Stories Acceptance Criteria Future

Slide 36

Slide 36 text

Stories Acceptance Criteria Code

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

identify the behaviour first

Slide 39

Slide 39 text

everything else

Slide 40

Slide 40 text

Outside-In

Slide 41

Slide 41 text

UX/IA/IxD Views Controllers Models Database

Slide 42

Slide 42 text

UX, IA, IxD

Slide 43

Slide 43 text

Views

Slide 44

Slide 44 text

Controller

Slide 45

Slide 45 text

Models

Slide 46

Slide 46 text

Database

Slide 47

Slide 47 text

An Example

Slide 48

Slide 48 text

In order to reduce time managing contacts users should be able to search for contacts within their account

Slide 49

Slide 49 text

searching contacts details Searching by partial name Given John Smith exists And I’ve logged in as a user When I search for Jo Then I should see John Smith is found

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

feature title

Slide 52

Slide 52 text

narrative

Slide 53

Slide 53 text

notes

Slide 54

Slide 54 text

acceptance criteria

Slide 55

Slide 55 text

scenario title

Slide 56

Slide 56 text

steps

Slide 57

Slide 57 text

Gherkin

Slide 58

Slide 58 text

PROJ_ROOT/ features/ step_definitions/ support/ searching_contacts.feature lib/ test/

Slide 59

Slide 59 text

cucumber features/searching_contacts.feature executable

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

pending steps

Slide 63

Slide 63 text

file/line numbers

Slide 64

Slide 64 text

step definition snippets

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

Given “John Smith” exists first step

Slide 67

Slide 67 text

PROJ_ROOT/ features/ step_definitions/ support/ searching_contacts.feature lib/ test/ people_steps.rb

Slide 68

Slide 68 text

features/step_definitions/people_steps.rb

Slide 69

Slide 69 text

watch it fail

Slide 70

Slide 70 text

watch it fail backtrace

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

make it pass

Slide 73

Slide 73 text

step becomes method invocation Given “John Smith” exists Given /^([^“]+)” .../ step definition becomes method definition

Slide 74

Slide 74 text

capture groups become arguments

Slide 75

Slide 75 text

And I’ve logged in as a user 2nd step

Slide 76

Slide 76 text

features/step_definitions/people_steps.rb

Slide 77

Slide 77 text

watch it fail

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

make it pass

Slide 80

Slide 80 text

When I search for “Jo” 3rd step

Slide 81

Slide 81 text

features/step_definitions/search_steps.rb

Slide 82

Slide 82 text

watch it fail

Slide 83

Slide 83 text

add routes

Slide 84

Slide 84 text

still failing

Slide 85

Slide 85 text

add controller

Slide 86

Slide 86 text

still failing

Slide 87

Slide 87 text

add view

Slide 88

Slide 88 text

still failing

Slide 89

Slide 89 text

add search action

Slide 90

Slide 90 text

still failing

Slide 91

Slide 91 text

add the model

Slide 92

Slide 92 text

made it pass

Slide 93

Slide 93 text

Then I should see “John Smith” is found last step

Slide 94

Slide 94 text

features/step_definitions/people_steps.rb

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

make it pass

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

Rinse Repeat Lather

Slide 99

Slide 99 text

Stories In Features Out

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

features - customer audience tests/specs - developer audience

Slide 103

Slide 103 text

accurate, readable, executable, features

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

step tables

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

table#raw

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

table#hashes

Slide 111

Slide 111 text

No content

Slide 112

Slide 112 text

table#rows_hash

Slide 113

Slide 113 text

scenario outlines

Slide 114

Slide 114 text

No content

Slide 115

Slide 115 text

No content

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

No content

Slide 118

Slide 118 text

multi-line strings

Slide 119

Slide 119 text

No content

Slide 120

Slide 120 text

background

Slide 121

Slide 121 text

No content

Slide 122

Slide 122 text

No content

Slide 123

Slide 123 text

tags tags

Slide 124

Slide 124 text

No content

Slide 125

Slide 125 text

No content

Slide 126

Slide 126 text

cucumber --tags @search, @wip

Slide 127

Slide 127 text

cucumber --tags ~@search,@wip

Slide 128

Slide 128 text

Hooks Transforms Framework Agnostic Wire Protocol Profiles

Slide 129

Slide 129 text

.NET - cuke4nuke

Slide 130

Slide 130 text

steps in .NET

Slide 131

Slide 131 text

JVM - cuke4duke

Slide 132

Slide 132 text

steps in java

Slide 133

Slide 133 text

steps in groovy

Slide 134

Slide 134 text

steps in scala

Slide 135

Slide 135 text

No content

Slide 136

Slide 136 text

Resources • http://www.cukes.info • http://github.com/aslakhellesoy/cucumber • http://github.com/aslakhellesoy/cuke4duke • http://github.com/richardlawrence/Cuke4Nuke/