You are on page 1of 12

BDD with EasyB

TDD
BDD
EasyB
JBehave

Michael Brunner
TDD - Test Driven Developement
 evolutionary design process
 Tests as specification not verification
 Grey-Box-Test
 TDD = Refactoring + TFD.
 „If the existing design is not the best design
possible for implementing that functionality,
then refactor it!”
 Kent Beck, who popularized TDD in eXtreme
Programming (XP) (Beck 2000), defines two
simple rules for TDD (Beck 2003).
– First, you should write new business code only
when an automated test has failed.
– Second, you should eliminate any duplication
that you find.
 Interfaces first, so you can mock them
 Feeling of success when tests turn green
TDD
 unit-testing framework must be available
 Tests are good, when they
– run fast (they have short setups, run times, and break downs).
– run in isolation (you should be able to reorder them).
– use data that makes them easy to read and to understand.
– use real data (e.g. copies of production data) when they need to.
– represent one step towards your overall goal.
Why BDD?

BDD = Behavior Driven Development


 People don‘t understand TDD because they
think about Testing
 But Testing is about Verification
Wrong Mindset
 Specification! (executable)
What‘s new in BDD?
 No xUnit, No Assertions
 But rSpec for Ruby, and shoulds
 BDD-Specifications are readable. Description in
normal language.
 Easy to understand for stakeholders.
 Tests segmented in given, when, then
How does BDD look like?

Scenario 1: Refunded items should be


returned to stock
 Given a customer buys a black jumper
 and I have three black jumpers left in stock
 when he returns the jumper for a refund
 then I should have four black jumpers in
stock
Tools
 Ruby
– RSpec
 Java
– EasyB
– JBehave
– JBee
– BeanSpec
 .Net
– NBehave
– NSpec
– MSpec
EasyB

 Stories
– given (a context)
– when (something happens)
– then (something else happens)
 Specification
– before
– it
EasyB – Story Eample
EasyB

 Supports Ant, Maven, CLI, IntelliJ, Eclipse


 Eclipse Plugin + Groovy Plugin = Code
Completion
 Uses Groovy for the iDSL
 Creates HTML, XML or Plain - Reports
 Can print the story without code
JBehave

 Specification as plain Text


 Code using Annotations
JBehave - Example
Given I am not logged in
When I log in as Liz with a password JBehaver
Then I should see a message, "Welcome, Liz!"

You might also like