際際滷

際際滷Share a Scribd company logo
Behavior Driven
 Development
    Chun-Wen Wang
     Aug 21, 2007
Background
TDD
Test Driven
Development
Behavior Driven Development
Problem
Developers dont know ...

 where to start
 what to test
 what not to test
 how much to test in one go
 what to call tests
 how to 鍖x a broken test
 that TDD is about design
Test?
Assert?
Sapir-Whorf
  hypothesis
Behavior Driven Development
BDD
Behavior Driven Development


 Its about writing speci鍖cations
 Its about writing how the code works
 Its about understanding how the system
  works
 Its about understanding what I have to write
BDD helps you realize

                                
    where to start                   outside-in
                                
    what to test                     user stories
                                
    what not to test                 anything else
                                
    how much to test in one go       as little as possible
                                
    what to call tests               intent
                                
    how to 鍖x a broken test          documentation
                                
    that TDD is about design         ......?!
Behavior

 The actions or reactions of an object or
  organism, usually in relation to the
  environment. -- Wikipedia


 Anything that an organism does involving
  action and response to stimulation. --
  Merriam-Webster
Example: Stack


 Stack
  as empty stack, ....
  as full Stack, ....
  neither empty nor full, ....
Example: Stack


                                    Speci鍖cation
    Stack
     as empty stack, ....
     as full Stack, ....
     neither empty nor full, ....
Example: Stack


 Stack                           Context
  as empty stack, ....
  as full Stack, ....
  neither empty nor full, ....
Example: Stack


 Stack
  as empty stack, ....           Behavior
  as full Stack, ....
  neither empty nor full, ....
Behavior of Empty Stack


 Empty stack
  is empty
  is no longer empty after push
  ...
Behavior of Empty Stack


 Empty stack                      Context
  is empty                        Behavior
  is no longer empty after push
  ...
How to Do It?

 JBehave - 1.0.1
  http://jbehave.org/
 JDave - 0.9.0
  http://www.jdave.org/
 Instinct - 0.1.4
  http://code.google.com/p/instinct/
Example (JDave)
<   >
Example using RSpec
</   >
Further More
Discussed    Not yet




       Module
      Under Test
Mock Objects
... arent Stubs
To be continued...
Q &A

More Related Content

Behavior Driven Development