Test Driven
Testing
Brendan Connolly
@theBConnolly
http://brendanconnolly.net
2
What Is TDD?
@theBConnolly
Why Should Testers Care?
Laws to Guide Us
3@theBConnolly
1.
4
No production code unless it is to
make a failing unit test pass
@theBConnolly
Software’s a Journey
Not a Destination
5
Fastest to Write Fastest to Maintain
@theBConnolly
How Do You Start
Testing?
6@theBConnolly
Organic Testing?
7@theBConnolly
1.
8@theBConnolly
No testing unless you have a
defined objective
Let Testers Be explorers,
9@theBConnolly
But...
Manage that exploration as a
series of expeditions
2.
10
You are not allowed to write any
more of a unit test than is sufficient
to fail.
@theBConnolly
Directions Vs. A Map
11@theBConnolly
Narrowly Focused Intentions 12@theBConnolly
2.
13@theBConnolly
Test only enough to satisfy the
objective
“ Joy comes in sips, not gulps
- Sharon Draper
14@theBConnolly
Break down work into chunks that
that fit into distraction free time
boxes.
3.
16
Write only enough production code
to pass one failing unit test
@theBConnolly
Hierarchy of Values
17
Building Discipline
@theBConnolly
Test small to Develop small
Prioritize for willpower
3.
18@theBConnolly
No activities outside the
objective
Tester Merit
Badges
19@theBConnolly
You don’t have to justify the
value of testers
Find A Bug?
20@theBConnolly
Stay within
the boundaries of intent
Intent Driven Testing
21@theBConnolly
Distractions Friction
Gain speed via Throughput
Functionally focused
Hierarchy of Values
22
Build Discipline
@theBConnolly
Work small to test small
The more you do, the more you
have to unwind and unpack
23
Red, Green, Refactor
@theBConnolly
24@theBConnolly
25@theBConnolly
...And Quality Emerges
“Figure out what test will best move your
code towards completion.
(Take as much time as you need. This is the
hardest step for beginners.)
-James Shore
26@theBConnolly
Think:
“
27@theBConnolly
“Making a commit at this point will improve
your process even more. You will have
autonomous chunks of work that are small
and easy to understand.
-Cecil Williams
28@theBConnolly
Commit:
“
29@theBConnolly
30
Test Driven
Testing Mantra
@theBConnolly
Think:
31@theBConnolly
Consider the high level testing strategy
Decide what task to pursue
Red:
32@theBConnolly
Establish clear intentions and outcomes
Decompose your goal
Green:
33@theBConnolly
Stay true to your charter
Take mindful action
Refactor:
34@theBConnolly
Shift from intuition to data driven
Unpack your observations
Commit:
35@theBConnolly
Investigate, Log, Communicate
Summarize Actions and Outcomes
This is hard
36@theBConnolly
Changing Habits
Building Discipline
Practice, Practice, Practice
37@theBConnolly
“ A choreographed pattern of
movements used to train
yourself to the level of
muscle memory
38@theBConnolly
Kata:
“ Simple problems not production code
Short (30-ish minutes)
Focus on form not solutions
39@theBConnolly
Code Kata’s
“
40@theBConnolly
Testing Kata’s
“
41@theBConnolly
Testing Kata’s: Stapler
“
42@theBConnolly
Testing Kata’s:
Pen
“
43@theBConnolly
Testing Kata’s:
Search Page
“ Apply Different Heuristics
Different Personas
Different Tools
44@theBConnolly
Testing Kata’s: Changing it
Up
Cycles
45@theBConnolly
“ Seconds - Follow the 3 Laws
46@theBConnolly
Cycles of TDD
Minutes - Red, Green, Refactor
10 Minutes - Specific / Generic Cycle
http://blog.cleancoder.com/uncle-bob/2014/12/17/TheCyclesOfTDD.html
“As the tests get more specific, the code gets
more generic
-”Uncle” Bob Martin
47@theBConnolly
Specific / Generic Cycle
“ Seconds - Follow the 3 Laws
48@theBConnolly
Cycles of TDD
Minutes - Red, Green, Refactor
10 Minutes - Specific / Generic Cycle
Hours - Architectural Boundaries
http://blog.cleancoder.com/uncle-bob/2014/12/17/TheCyclesOfTDD.html
“
49@theBConnolly
Cycles of Test Driven Testing
Minutes - Follow the 3 Laws
30 Minutes-ish - Think, Red, Green,
Refactor, Commit
Hours-ish - Specific / Generic Cycle
As testers intentions get more
specific
The testers perspective becomes
more holistic
50@theBConnolly
Be Well, Create, Share
Connect With Me
@theBConnolly
brendanconnolly.net
|

Test Driven Testing

Editor's Notes

  • #5 But there is nothing to test, Forces test first. Solutions tend to grow organically Requirements tell us what software has to do, but its often developer discretion on how those requirements are implemented.
  • #6 Organic growth vs. explicit design Designers don’t always end up consumers of their designs. Existing code is read much more often that new code is written
  • #8 Sometimes our efforts drift, navigating by gut feelings and intuituions. Its not bad but its good to have a lens to focus our efforts
  • #9 TDD isn’t a magic bullet, good patterns can emerge Can have strategy without needing test plan written up front. It’s fine for the first mission to be a scouting mission, consider rules of engagement
  • #10 Be free to gather information,
  • #11 Clear intent doesn’t mean we aren’t overly ambitious. TDD is like a microcosm of an agile transition. We don’t want to drive decisions by just what we think. Instead force a feedback cycle to drive
  • #12 New features are like being in a new place, knowing you need to get somewhere, but your only tool is a wrinkled map. All you really want is someone to give you directions, but thats a lot of trust and risk You are making decisions when yo uknow the least.
  • #13 We made a plan, but now we feel compelled to follow that plan Replace the baggage of a plan, a series of distance intervals that result in arriving at the destination
  • #14 Planning testing up front introduces the same baggage, sunk costs
  • #17 We now treat test and production code as 2 sides of the same coin
  • #18 Tests first puts the priority on process over destination The cycle has to feed itself a
  • #19 Processing information is a difficult task, multi tasking is impossible.
  • #20 We sometimes look for bugs to grant us team credibility. We are looking to justify contributions
  • #21 We aren’t bug hunters thats just an artifact Wouldn’t you rather evaluate software on its merits not its flaws Bugs a
  • #22 Many dimensions to testing, context shifting, persona bleeds Be active in present in testing rather than a passive
  • #23 Put tester willpower requiring tasks first The more we do the more we have to un
  • #24 A mantra for devs doing TDD
  • #25 Super relatable but where does design step in? It can’t just
  • #26 Super relatable but where does design step in? It can’t just