Below And Beneath Tdd Test Last Development And Other Real World Test Patterns Presentation - Presentation Transcript
Below And
Beneath TDD
Test-Last Development and other
real world test patterns
Noel Rappin
@noelrap
Pathfinder Development
pathf.com
railsprescriptions.com
http://www.railsrx.com
TEST REFACTOR
FAIL PASS
CODE Rx
TEST REFACTOR
Why does testing work?
FAIL PASS
Why does testing fail?
CODE Rx
TEST REFACTOR
What does it mean for
testing to “work”?
FAIL PASS
CODE Rx
TEST REFACTOR
Improve effectiveness
of team and
quality of code
NOT
FAIL PASS
A perfect guarantee of
code correctness
CODE Rx
TEST REFACTOR
for me, tdd is about
confidence &
accountability &
responsibility & design &
reusability & portability &
flexibility & testing &
FAIL PASS
trustworthiness &
teamwork & initiative &
flow & that's all i can
think of at the moment.
CODE
-- Kent Beck
Rx
TEST REFACTOR
Accurate view of code
Small, incremental steps
FAIL PASS
Scaffold for change
Focus for development
CODE Rx
TEST REFACTOR
What does it mean for
testing to “fail”?
FAIL PASS
CODE Rx
TEST REFACTOR
Decrease efficiency and
code quality
FAIL PASS
CODE Rx
TEST REFACTOR
“It feels like there's a
hidden door that everyone
who tests has found and
walked through...
There are a bunch of us...
FAIL PASS
that would love to join
the party, but don't know
where to find
the door.”
CODE Rx
TEST REFACTOR
If you are stuck in a
window or banging your
head against the wall,
FAIL PASS
this will help
you get to the door
CODE Rx
TEST REFACTOR
FAIL PASS
CODE Rx
TEST REFACTOR
Test-Driven
Development
FAIL PASS
CODE Rx
TEST REFACTOR
AKA: Behavior-Driven
Development
or
FAIL PASS
Test-First
Programming
CODE Rx
TEST REFACTOR
TDD Code has:
small pieces
FAIL PASS
high cohesion
loose coupling
minimal side-effects
CODE Rx
TEST REFACTOR
☺Accurate view of code
☺Small, incremental steps
FAIL PASS
☺Scaffold for change
☺Focus for development
CODE Rx
TEST REFACTOR
FAIL PASS
CODE Rx
TEST
Lose the refactoring
FAIL PASS
CODE Rx
TEST
Development, that
FAIL PASS
happens
to have tests
CODE Rx
TEST
Symptoms:
FAIL PASS
Increased duplicaton in
code.
Long methods
CODE Rx
TEST
Benefits:
FAIL PASS
May seem faster at first
CODE Rx
TEST
Over time...
FAIL PASS
CODE Rx
TEST
☺Accurate view of code
Small, incremental steps
FAIL PASS
Scaffold for change
☺Focus for development
CODE Rx
TEST
Fix by:
FAIL PASS
Cleaning up your mess
CODE Rx
TEST REFACTOR
FAIL PASS
CODE Rx
TEST REFACTOR
FAIL PASS
TEST
FAIL
CODE Rx
TEST REFACTOR
assert_equal(nil, actual) assert_equal(4.314, actual)
FAIL PASS
TEST
actual = 4.314
FAIL
CODE Rx
TEST REFACTOR
Data-Driven Testing
or
FAIL PASS
Using your program
as a calculator
TEST
FAIL
CODE Rx
TEST REFACTOR
Benefits:
Failed Test Guaranteed
FAIL PASS
Value may be hard to
calculate TEST
FAIL
CODE Rx
TEST REFACTOR
Pitfalls:
Can mask ignorance
of domain
FAIL PASS
Can lead to worse
TEST
problems
FAIL
CODE Rx
TEST REFACTOR
Accurate view of code
☺Small, incremental steps
FAIL PASS
☺Scaffold for change
☺Focus for development TEST
FAIL
CODE Rx
TEST REFACTOR
assert_equal(nil, actual) assert_equal(4.314, actual)
FAIL PASS
TEST
actual = 4.314
FAIL
CODE Rx
REFACTOR
CODE
actual = 4.314
assert_equal(4.314, actual)
PASS
TEST
Rx
CODE REFACTOR
Test-Next Development
aka
PASS
Code-Driven
Development
TEST
Rx
CODE REFACTOR
Symptoms:
No more failing tests
Tweaking tests to
PASS
match code
Coverage drop
TEST
Rx
CODE REFACTOR
Benefits:
Useful when exploring
PASS
Useful when testing
views
TEST
Rx
CODE REFACTOR
Pitfalls:
Easily slides into worse
patterns
PASS
Hard to avoid
coverage gaps
TEST
Rx
CODE REFACTOR
Accurate view of code
☺Small, incremental steps
PASS
Scaffold for change
Focus for development
TEST
Rx
CODE REFACTOR
Tautology Based
Development
PASS
TEST
Rx
CODE REFACTOR
Definition:
Tests that can’t
PASS
fail
TEST
Rx
CODE REFACTOR
Symptoms:
Bugs that should have
been covered
PASS
Mock object
misuse
TEST
Rx
CODE REFACTOR
☹Accurate view of code
☺Small, incremental steps
PASS
Scaffold for change
☹Focus for development
TEST
Rx
CODE REFACTOR
Mitigation:
Try to separate
code assertions
PASS
from application
data
TEST
Rx
0 comments
Post a comment