dependability
build trust
know immediately when you break something
Slide 22
Slide 22 text
loose coupling
easy to test
not just a buzzword
Slide 23
Slide 23 text
how do you test?
Slide 24
Slide 24 text
setup
exercise
verification
teardown
Slide 25
Slide 25 text
same process for any language
test methods run in isolation
let's do some ruby
Slide 26
Slide 26 text
require 'test/unit'
class BillsPlayerTest < Test::Unit::TestCase
def test_to_is_a_tad_bit_hyped
end
end
Slide 27
Slide 27 text
setup
terrell_owens = BillsPlayer.new
Slide 28
Slide 28 text
exercise
terrell_owens.overpaid?
Slide 29
Slide 29 text
verification
assert
Slide 30
Slide 30 text
other assertions
assert_equal "wide receiver",
terrell_owens.position
assert_not_nil terrell_owens.number
assert_raises InterceptionError do
terrell_owens.miss_route!
end
Slide 31
Slide 31 text
class BillsPlayerTest < Test::Unit::TestCase
def test_to_is_a_tad_bit_hyped
terrell_owens = BillsPlayer.new
assert terrell_owens.overpaid?
end
end
Slide 32
Slide 32 text
class BillsPlayerTest < Test::Unit::TestCase
def setup
@terrell_owens = BillsPlayer.new
end
def test_to_is_a_tad_bit_hyped
assert @terrell_owens.overpaid?
end
def teardown
# bills lose, again :[
end
end
Slide 33
Slide 33 text
so what?
production errors due to uncomprehensive tests
often done after the code is written
if not automated, not preformed frequently
and so on...
Slide 34
Slide 34 text
test driven development
Slide 35
Slide 35 text
you, the developer, write the tests!
write tests before implementation
new code only when an automated test fails
take small steps
Slide 36
Slide 36 text
the process
write a test
watch it fail
write just enough code to make it pass
Slide 37
Slide 37 text
let's do this
Slide 38
Slide 38 text
feedback loop
red
green
refactor
Slide 39
Slide 39 text
refactor
eliminate duplication
rename
single responsibility
and so on...
Slide 40
Slide 40 text
tdd is about design
design is a process, not a phase
think about the interface before
implementation