specification by examplefc.put.poznan.pl/materials/139-specification-by... · characteristics of...

Post on 16-Jul-2020

3 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Specification By Example smarter way to create software

by Maciej Klepacki

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

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

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>

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!

User Stories as backbone in SBE

Use

r S

tory

(G

iven

/When

/Then

)

Testers

Analyst

Developers

Features

Happy path scenarios

Alternate scenarios

How does SbE fit to standard documentation

Features = User Requirements Specification

Scenarios = Functional & Non-functional Specification

Examples = Test Data

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.

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/

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)

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

Show of code structure

• Visual Studio file structure

• Nunit test suite structure

Any questions?

top related