Top Banner
Behaviour Driven Development with Cucumber
18

Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Apr 14, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Behaviour Driven Development

with Cucumber

Page 2: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

2 04.07.2012

Introduction

Page 3: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Sapir–Whorf Hypothesis

3 04.07.2012

People who speak different languages

perceive and think about the world quite

differently.

Page 4: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Behaviour Driven Development

A way to describe the requirement such that everyone

the business folks,

the developer,

the tester

and others

has a common understanding of the scope of work.

A description of a requirement and its business benefit, and a set of criteria by which

we all agree that it is “done”.

4 04.07.2012

Page 5: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Introduction

The workflow

Developer and stakeholder collaborate to write automated tests.

Software is accepted if automated tests pass.

Automated acceptance tests as …

ubiquitious language for everybody

a means of collaboration and discussion

living documentation

5 04.07.2012

Page 7: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Describe Features in the Gherkin Language

Feature

Requirements are descriped as Features

A feature contains many Scenarios.

Scenario

Desired behaviour is described as Scenario.

All scenarios follow the same pattern:

1. Get the system into a particular state.

2. Poke it (or tickle it, or ...).

3. Examine the new state.

Those three parts are identified by the following keywords

Scenario: Successful withdrawal from an account in credit

Given I have $100 in my account # the context

When I request $20 # the event(s)

Then $20 should be dispensed # the outcome(s)

7 04.07.2012

Page 8: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Cucumber Testing Stack

8 04.07.2012

Page 9: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

9 04.07.2012

BDD in CPM

Page 10: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Motivation

How can we document the fullfillment of a regulation to external revision?

For that we need

easy readable documentation for requirements and tests

reports on what has been tested and when

10 04.07.2012

Page 11: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

BDD in CPM

Spike with BDD to test Conflict Minerals Regulation.

CPM Admin Console developed with BDD

11 04.07.2012

Page 12: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Example CPM Admin Console

Defining the Features

Running the Features

Documenting the Features.

12 04.07.2012

Page 13: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Example CPM Admin Console

Define the Feature Health Check

Feature: Check Health of CPM Server

Scenario: Health check is successful if the server is available.

Given The server is <available>.

When I run the admin console with arguments `-c`

Then the output contains "up and running".

Scenario: Health check fails if the server is not available.

Given The server is <not available>.

When I run the admin console with arguments `-c`

Then the output contains "not available".

Scenario: Health check uses default url if the server is not specified.

Given The server is <not specified>.

When I run the admin console with arguments `-c`

Then the output contains "not available".

And the output contains "http://localhost:8080/cpm".

13 04.07.2012

Page 14: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Example CPM Admin Console

Defining the Features

Each Features is defined in its own file e.h. argumentValdiation.feature

Feature files are under source control (in Github).

14 04.07.2012

Page 15: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Example Admin Console

Running the Features

Developers run the Features in their IDE during development

15 04.07.2012

Page 16: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Example Admin Console

Running the Features

Features are executed automatically during every build in Jenkins

16 04.07.2012

Page 17: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

Example Admin Console

Documenting the Features

Report for the features is generated during the build

17 04.07.2012

Page 18: Behaviour Driven Development with Cucumber · 2017-12-06 · Behaviour Driven Development A way to describe the requirement such that everyone the business folks, the developer, the

18 04.07.2012

Questions