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() {}
Behavior
is also described
by Business Analysts
Eric Evens:
ubiquitous language
Chris Matts
The Business Analyst GOAL:
readable requirements
and automated
acceptance tests
GIVEN
WHEN
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: Title

Given [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 customer
I want to add items to my shopping cart
So that I can place an new order
Scenario: Customer should add an item
to shopping cart
Given a shopping cart
When a customer adds an item to his shopping cart
Then 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

BDD with JBehave

  • 1.
    BDD & JBehave emphasizebehavior over testing
  • 3.
  • 4.
    introduction Dan North want to improveTDD a unit test is more meaningful in a full sentence should_login_a_user_to_his_account() {} Behavior is also described by Business Analysts Eric Evens: ubiquitous language Chris Matts The Business Analyst GOAL: readable requirements and automated acceptance tests GIVEN WHEN THEN
  • 5.
  • 6.
    principles Business Goal Stories Examples ExecutableSpec Low Level Specification user stakeholder business analyst
  • 7.
    principles Business Goal Stories Examples LowLevel Specification user stakeholder business analyst developer tester ops user stakeholder business analyst Executable Spec
  • 8.
    BDD TDD Failing Acceptance Test Failing UnitTest Test Pass Refactor BDD and TDD Acceptance Pass
  • 10.
    write a Story Title   Narrative: As a [role] I want [feature] So that [benefit]   Scenario 1: Title Given [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 customer I want to add items to my shopping cart So that I can place an new order Scenario: Customer should add an item to shopping cart Given a shopping cart When a customer adds an item to his shopping cart Then the shopping cart contains 1 different item
  • 12.
  • 13.
  • 14.
    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
  • 17.
    bibliography Books BDD in Action GrowingObject-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