the lazy developer's guide to bdd (with cucumber)

Post on 14-May-2015

4.235 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

The slides for my presentation at GeekCamp.sg 2009.

TRANSCRIPT

A LAZY Developer's Guide to BDD

(with )~ Ng Tze Yang (aka TY)

2

Everyone gets a little of 's ♥

2 weeks ago, i changed it to:

3

A LAZY Developer's Guide to BDD

(with )

4

WTF is “LAZY” ??

5

LAZY= !(TATFT)

6

WTF is “TATFT” ??

7

8

Why Not TATFT ??

9

Why Not TATFT ??

* What is most important for a software ??

10

Why Not TATFT ??

* What is most important for a software ??

=> Business Value

11

Why Not TATFT ??

* What is most important for a software ??

=> Business Value

* How do we quantify BV ??

12

Why Not TATFT ??

* What is most important for a software ??

=> Business Value

* How do we quantify BV ??

=> Behaviours

13

BDD~ Behaviour Driven Development ~

14

BDD~ Behaviour Driven Development ~

“BDD facilitates agile development, which is an approach to develop functional

software, within reasonable timeline, making everyone happy, without killing anyone, or

burning down any bank.”

15

BDD's Core Principles

16

BDD's Core Principles

* It's all behaviour

“ The business & technology people should be speaking the same words

when referring to the same idea, there should not be any translator.”

17

BDD's Core Principles

* It's all behaviour

Behaviour: the addition of N values should yield the summation of them

Example: the addition of 2 + 4 +1 should yield 8

18

BDD's Core Principles

* It's all behaviour

* Deliver stakeholder value

“ Whatever u are doing, it should be delivering business value, or increasing ur ability to deliver value, if the activity

doesn't acheive this, stop doing it”

19

BDD's Core Principles

* It's all behaviour

* Deliver stakeholder value

“ Unit testing is important, as it makesrefactoring & regression testing easier, which eases maintenace and enhance ur ability to

deliver newer features faster”

20

BDD's Core Principles

* It's all behaviour

* Deliver stakeholder value

* Enough is enough

“ Do not overengineer, do not overdo upfront planning, analysis and design.

Do just enough to get things started in the right direction”

21

BDD's Core Principles

* It's all behaviour

* Deliver stakeholder value

* Enough is enough

“ When i wanna go to sentosa from my AMKhome, i just goto gothere.sg to do a quick

check, and that's good enough, i don't needto get down to switching lanes on CTE,

blah blah. ”

22

Cucumber ? Nice to Eat ?!

23

Cucumber ? Nice to Eat ?!

* a tool for functional testing

24

Cucumber ? Nice to Eat ?!

* a tool for functional testing

* by Aslak HellesØy, & many other nice people

25

Cucumber ? Nice to Eat ?!

* a tool for functional testing

* allows non-technies to express app's functions in plain text

* by Aslak HellesØy, & many other nice people

26

Cucumber ? Nice to Eat ?!

* a tool for functional testing

* allows non-technies to express app's functions in plain text

* plain text serves as documentation & executable examples

* by Aslak HellesØy, & many other nice people

27

Hmm .. Plain Text ?!

28

A Prettier Plain Text

29

The Title

30

The Narrative

31

Guideline for the Narrative

32

Guideline for the Narrative

* identify the stakeholder

“ Eg. The system administrator”

33

Guideline for the Narrative

* identify the stakeholder

* describe the feature he wants

“ Eg. Trashing of all invalid purchase orders in the system”

34

Guideline for the Narrative

* identify the stakeholder

* describe the feature he wants

* the reason for wanting it

“ Eg. Prevent data corruption”

35

The Acceptance Criterion

36

The Scenario's Title

37

The Scenario's Steps

38

Given | When | Then

39

Given | When | Then

* GIVEN ... setting up system to a known state

“ Eg 1. Database setup ...Given the following users already exists”

“ Eg 2. Visiting a Url ...Given I am on users management page”

“ Eg 3. Ensure User's Login ...Given I already login as “HappyMan””

40

Given | When | Then

* GIVEN ... setting up system to a known state

* WHEN ... exercising an event

“ Eg. Pressing Button ...When I press “Help Me””

41

Given | When | Then

* GIVEN ... setting up system to a known state

* WHEN ... exercising an event

* THEN ... verifying an outcome

“ Eg. Seeing a message ...Then I should see “Login Successful””

42

Save & Execute It !!

<PROJECT_ROOT> `~ features/ `- sign_up.feature

* Save at:

43

Save & Execute It !!

<PROJECT_ROOT> `~ features/ `- sign_up.feature

* Run with: #$ cucumber features

* Save at:

44

P1

P2

45

46

47

48

49

50

51

52

Step Definitions

53

Save & Execute It !!

<PROJECT_ROOT> `~ features/ `- steps.rb

* Save as:

54

Save & Execute It !!

<PROJECT_ROOT> `~ features/ `- steps.rb

* Save as:

* Run with: #$ cucumber features

55

56

57

58

The Functional Test Model

59

The Generic Model

Cucumber* cucumber exec* features/*.feature* features/*.rb

60

The Generic Model

Cucumber* cucumber exec* features/*.feature* features/*.rb

Target App

61

The Generic Model

Cucumber* cucumber exec* features/*.feature* features/*.rb

Target App

Driver

62

The Generic Webapp Model

Cucumber* cucumber exec* features/*.feature* features/*.rb

63

The Generic Webapp Model

Cucumber* cucumber exec* features/*.feature* features/*.rb

Webapp* web server* deployed app* web browser

64

The Generic Webapp Model

Cucumber* cucumber exec* features/*.feature* features/*.rb

Webapp* web server* deployed files* web browser

Driver* selenium (server+client)

65

FAST FOWARD(Completed: Step Definitions)

66

Before

After

67

Before

After

68

Before

After

69

Before

After

70

Before

After

71

A New *.rb File

<PROJECT_ROOT> `~ features/ `- selenium.rb

72

73

74

75

76

77

OK, Let's Run It !!

#$ cucumber features

78

79

80

Run Selenium Server

#$ selenium

81

Run Selenium Server

#$ selenium

82

83

Let's Try Again

#$ cucumber features

84

85

86

The Missing Part ??

~ Our Application ~

87

FAST FOWARD AGAIN(Completed: Application)

88

Let's Run the Webapp

#$ ruby app.rb

89

Let's Run the Webapp

#$ ruby app.rb

90

91

Let's Try Once Again

#$ cucumber features

92

Let's Try Once Again

#$ cucumber features

93

Revision Time

94

Summing Up

1) Capturing user's requirements in a feature file

95

Feature's Title

96

Feature's Narrative

97

Feature's Narrative

98

Feature's Narrative

99

Feature's Narrative

100

Feature's Acceptance Criterion

101

Feature's Acceptance Criterion

102

Feature's Acceptance Criterion

103

Summing Up

2) Complete the missing step defintions

1) Capturing user's requirements in a feature file

104

Step Definitions

105

Summing Up

3) Implement the application

1) Capturing user's requirements in a feature file

2) Complete the missing step defintions

106

Useful Links

* Cucumber's Wiki http://wiki.github.com/aslakhellesoy/cucumber

* Cucumber's Homepage http://cukes.info/

* BDD @ Wikipedia

107

Recommended Video

108

THE END

top related