bdd

14
BDD BEHAVIOUR DRIVEN DEVELOPMENT

Upload: machielg

Post on 15-Apr-2017

82 views

Category:

Software


0 download

TRANSCRIPT

Page 1: BDD

BDDBEHAVIOUR DRIVEN DEVELOPMENT

Page 2: BDD

NO INTEGRATION TESTTWO UNIT TESTS PASSED

Page 3: BDD

WOULDN’T IT BE GREAT?

• Clear requirements

• Measurable acceptance criteria

• Documentation of existing functionality

• Confidence everything works?

Page 4: BDD

“WHAT’S THE PURPOSE OF MEANING?”

WHAT IS BDD

A. A way to structure unit tests

B. Unit tests with a new name

C. Executable specifications

D. Automated Test Scenarios

Page 5: BDD

FORMB.D.D.

Given [initial state]

When [do stuff]

Then [result]

Page 6: BDD

B.D.D.

EXAMPLE

Feature: Green Bottles

Scenario: Should fall from the wall

Given 100 green bottles are standing on the wall

When 1 green bottle accidentally falls

Then there are 99 green bottles standing on the wall

Page 7: BDD

“MAKE IT RUN”THE CODE

module.exports = English.library()

.given("$NUM green bottles are standing on the wall", function(number, next) {

wall = new Wall(number);

next();

})

.when("$NUM green bottle accidentally falls", function(number, next) {

wall.fall(number);

next();

})

.then("there are $NUM green bottles standing on the wall", function(number, next) {

assert.equal(number, wall.bottles);

next();

});

Page 8: BDD

EXECUTE IT!

macbookpro:yadda-tutorial machiel$ mocha --reporter spec test.js

100 Green Bottles Should fall from the wall ✓ Given 100 green bottles are standing on the wall ✓ When 1 green bottle accidentally falls ✓ Then there are 99 green bottles standing on the wall

3 passing (34ms)

Page 9: BDD

DONEC QUIS NUNC

ALTERNATIVE: CODE DECORATION

describe("A suite", function() {

it("contains spec with an expectation", function() {

expect(true).toBe(true);

});

});

A suitecontains spec with an expectation

Page 10: BDD

DIVIDE ET IMPERA

ONE SCENARIO TO RULE THEM ONE

SCENARIO

SERVER SIDE TEST

UI TEST

MULTI BROWSER

TEST

PERFORMANCE TEST

Page 11: BDD

“COMPARISON IS THE THIEF OF JOY”BDD VS TDD

• Unit

• One function or class

• language of the system

• fine grained

• Behaviour

• the whole system

• language of the user

• coarse

Page 12: BDD

BENEFITS

USER LEVEL TESTS

• Test linked to Story

• Done or not

• Technology agnostic

• Multiple usages

• Refactor friendly

Page 13: BDD

CLARITY SECURITYSPEED

BDD IN A NUTSHELL

Page 14: BDD

LIBRARIES

Pure BDD in JS https://github.com/acuminous/yadda

Yadda in crossbrowser testing https://github.com/kjelloe/Yadda-WebdriverJS