17
BDD & JBehave emphasize behavior over testing

BDD with JBehave

Embed Size (px)

Citation preview

BDD & JBehave emphasize behavior over testing

right software

software right

unmaintainable

business failure success

atomic fail!

problem

introduction

Dan North want to

improve TDD

a unit test is more meaningful in a full sentence

should_login_a_user_to_his_account() {}

Behavioris also described

by Business Analysts

Eric Evens: ubiquitous language

Chris Matts The Business Analyst GOAL:

readable requirements and automated

acceptance tests

GIVENWHEN THEN

principles

Business Goal Stories

Examples

Executable Spec

Low Level Specification

principles

Business Goal Stories

Examples

Executable Spec

Low Level Specification

user stakeholder business analyst

principles

Business Goal Stories

Examples

Low Level Specification

user stakeholder business analyst developer tester ops

user stakeholder business analyst

Executable Spec

BDD

TDD

Failing Acceptance Test

Failing Unit Test

Test Pass

Refactor

BDD and TDD

Acceptance Pass

write a Story

Title  Narrative:As a [role]I want [feature]So that [benefit]  Scenario 1: TitleGiven [context]  And [some more context]...When  [event]Then  [outcome]And [another outcome]...  Scenario 2: ...

Title: A customer should add items to his cart

Narrative:As a customerI want to add items to my shopping cartSo that I can place an new order

Scenario: Customer should add an item to shopping cart

Given a shopping cartWhen a customer adds an item to his shopping cartThen the shopping cart contains 1 different item

now JBehave

make the specification executable

at a glance

Pros

• reduces waste • changes are saver • spread the knowledge • brings the team together • domain language • find design smells • serves as documentation • (reduces costs)

Keep in mind

• high business engagement • don’t use with design up front • won’t work in silos • bad tests lead to bad code

bibliography

Books BDD in Action Growing Object-Oriented Software, Guided by Tests Specification By Example ATDD By Example

Online http://dannorth.net/whats-in-a-story/ https://weblogs.java.net/blog/manningpubs/archive/2013/06/10/introducing-behavior-driven-development http://technologyconversations.com/category/behavior-driven-development-bdd/ http://www.thoughtworks.com/insights/blog/qa-role-what-it-really http://www.jbehave.org