Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of...

14
Specification By Example smarter way to create software by Maciej Klepacki

Transcript of Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of...

Page 1: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Specification By Example smarter way to create software

by Maciej Klepacki

Page 2: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Characteristics of Specification By Example

(Behavior Driven Development)

• Scope is directly steered by business goals

• User Stories are created together with business – this is critical for SBE success

• Scenarios are written in natural language with keywords

• Scenarios describe key ways to use the system

• Scenarios are:

- Requirements Specification – a living documentation

- Test Scripts for UAT

- Basis for automated regression tests

- Check-list for developer

Page 3: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Construction of User Story - Feature

• Clear Title

Good Feature: User sends information to Service support

Bad Feature: Using Webform

• Clear business goal (not easy!)

As a Service user

I want to inform Service support about my problem

So that the problem gets resolved

• Definiton of preconditions for all scenarios

Background:

Given I am a Service User

And I have Service web form page open

Page 4: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Construction of User Story - Scenario

• User Action

When I choose my <location>

And I enter <title> of the message

And I enter <description> of the problem

And I define the <priority> of the problem

And I send the entered information

• Set of example data (for Scenario Outline)

Example:

| title | description | priority | impact | location| group |

|Problem!| Test Test Test | Urgent | High | Polska | Europe |

• System Reaction

Then a new ticket is created, containing:

| <title>| <description> | <priority> |

And is assigned to proper <group> based on

<location>

Page 5: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Non-functional requirements and SbE

Example:

Given I am an Authorized User

And I operate between 9 to 17

And less than 1000 users are logged in

When I open XYZ page

Then it loads in less than 5 seconds

Security

Availability

Capacity

Performance

... other non-functional requirements

can be described in similar way!

Page 6: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

User Stories as backbone in SBE

Use

r S

tory

(G

iven

/When

/Then

)

Testers

Analyst

Developers

Features

Happy path scenarios

Alternate scenarios

Page 7: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

How does SbE fit to standard documentation

Features = User Requirements Specification

Scenarios = Functional & Non-functional Specification

Examples = Test Data

Page 8: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Why automate tests with SBE approach?

• Test Automation is based on natural language – it is easy to understand what

the test does.

• It is possible to create first single function tests and then combine them into

more complex regression tests matching Business Flow for.

• It is easy to choose the right tests for execution and to maintain them later.

• It is possible to distinct test scenario creation from technical implementation –

possibility to use people with different skills.

• It is a way to standardize test script language.

• It is easy to report automated tests outcome.

• Implementations for different languages present: Ruby, Java, Python, .NET and

more.

Page 9: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

SbE implementations

• Specflow – C#:

http://www.specflow.org/

• Cucumber – Ruby (also ported to: java, python, php):

http://cukes.info/

• Rbehave – Ruby:

http://dannorth.net/2007/06/17/introducing-rbehave/

• Jbehave - Java:

http://jbehave.org/

Page 10: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Why .NET implementation?

• Visual Studio offers greater productivity then Eclipse for SBE

• Specflow for .NET integrates seamlessly with Visual Studio – no interfaces needed

• NUnit offers more functions then JUnit

• Great reporting tool out-of-the-box

• Relatively flat learning curve for new users (rich training materials from Microsoft)

Page 11: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Scheme of SBE implementation using .NET:

SpecFlow+Webdriver+NUnit

SPECFLOW

parser pre i post

procesor

Feature

+ Scenario

(Given/When/Then)

Step

Definition

Page

Objects

Webdriver

Browser steering

Nunit

Test execution

HTML

Report

XML

Report

Browser

Calls

Uses Action

Uses

Test List

Reaction

Test result

Generates

Is read

Page 12: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Show of code structure

• Visual Studio file structure

• Nunit test suite structure

Page 14: Specification By Examplefc.put.poznan.pl/materials/139-specification-by... · Characteristics of Specification By Example (Behavior Driven Development) • Scope is directly steered

Any questions?