“The Only Way to Test!”
Keith Pitty
!
@keithpitty
Who’s telling you
the right way to test?
So… who is right?
Let’s engage our
brains!
What’s being posited?
James Coplien: “Why Most
Unit Testing is Waste”
Comprehensive, well-argued article
Well worth reading with an open mind
May challenge your preconceptions
James Coplien: “Why Most
Unit Testing is Waste”
“Keep unit tests that test key algorithms for which
there is a broad, formal, independent oracle of
correctness, and for which there is ascribable
business value.”
James Coplien: “Why Most
Unit Testing is Waste”
“Throw away tests that haven’t failed in a year.”
James Coplien: “Why Most
Unit Testing is Waste”
“Be humble about what tests can achieve. Tests
don’t improve quality: developers do.”
Bob Martin: “Monogamous
TDD”
argues that TDD does have significant value
Bob Martin: “Monogamous
TDD”
trustworthy, fast
test suite
fearless, quick
code cleaning
Gary Bernhardt: “TDD, Straw
Men, and Rhetoric”
aims for test feedback in 300ms
Gary Bernhardt: “TDD, Straw
Men, and Rhetoric”
tests respond before he has time to think
Gary Bernhardt: “TDD, Straw
Men, and Rhetoric”
“TDD is useful and test isolation is useful,
but they both involve making trade-offs.”
Corey Haines: “Speeding Up
ActiveRecord Tests"
Specific suggestion to speed up ActiveRecord tests
using his active_record_spec_helper
Corey Haines: “Speeding Up
ActiveRecord Tests"
Isolation: only include the parts of the system
that are necessary
Martin Fowler, Kent Beck &
DHH: “Is TDD Dead?”
Five discussions totally about three hours
Martin Fowler, Kent Beck &
DHH: “1. TDD and Confidence”
KB: TDD can, but does not necessarily, lead to flow
DHH: doesn’t like the conflation of TDD and
confidence from self-testing code
MF: heavy mocking isn’t mandatory in TDD
Martin Fowler, Kent Beck & DHH:
“2. Test-induced design damage”
KB to DHH: “TDD isn’t taking you anywhere.
You’re making the decisions.”
Martin Fowler, Kent Beck &
DHH: “3. Feedback and QA”
MF: categories of feedback:
1. user needs
2. regression tests
3. healthy codebase
DHH: notion of criticality
KB: it’s a continuum and set of trade-offs
Martin Fowler, Kent Beck &
DHH: “3. Feedback and QA”
“As soon as you think you’re not making
mistakes, you’re making mistakes.”
— Kent Beck
Martin Fowler, Kent Beck &
DHH: “4. Costs of Testing”
DHH: some tests are not justified
KB: delta coverage
MF: only test things that could possibly break
DHH: insufficient energy in refactoring
Martin Fowler, Kent Beck &
DHH: “5. Q & A; Summary”
KB: TDD helps problems to be broken down
MF: TDD with refactoring has often led to
good design
DHH: “most people cannot leave good ideas
the fuck alone”
Martin Fowler, Kent Beck &
DHH: “5. Summary”
KB: TDD is not dead but thanks for setting fire to it
DHH: TDD shouldn’t be mandated but we don’t
want to lose self-testing code
MF: if you’re going to be involved in software
development you have to be thoughtful
What do I think?
important to appreciate
each other’s different
experiences
I value TDD in some
situations
I also value other
forms of feedback
I sometimes write
regression tests last
I think it’s always
important to consider
how valuable a test is
I know I still have a lot
to learn
What do you think?
In summary…
Learn from others
Consider the context
Think for yourself!
References
• http://david.heinemeierhansson.com/2014/tdd-is-dead-long-live-testing.html
• http://david.heinemeierhansson.com/2014/slow-database-test-fallacy.html
• http://www.rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.pdf
• http://blog.8thlight.com/uncle-bob/2014/04/25/MonogamousTDD.html
• https://www.destroyallsoftware.com/blog/2014/tdd-straw-men-and-rhetoric
• http://articles.coreyhaines.com/posts/active-record-spec-helper/
• http://martinfowler.com/articles/is-tdd-dead/
More References
• “Growing Object-Oriented Software, Guided by
Tests”, Steve Freeman & Nat Price
• “Rails 4 Test Prescriptions: Build a Healthy
Codebase”, Noel Rappin
• “Perfect Software and other illusions about
testing”, Gerald M. Weinberg
Thanks for listening
The Only Way to Test!

The Only Way to Test!