SlideShare a Scribd company logo
Lessons from Testing 
examples taken 
from 
http://cyber-dojo.org 
@JonJagger 
jon@jaggersoft.com 
1 
Thursday, 23 October 14
Avoid unnecessary 
burning of calories! 
2 
Thursday, 23 October 14
FizzBuzz 
3 
Thursday, 23 October 14
what do I notice? 
E09E8C snake 4 
Thursday, 23 October 14
5 
Thursday, 23 October 14
Suppose we measure 
the average cyclomatic 
complexity of the code 
under test and the test 
code. 
6 
Thursday, 23 October 14
Higher number 
means more 
complex. 
7 
Thursday, 23 October 14
tests code 
3.7 > 2.1 
8 
Thursday, 23 October 14
tests code 
3.7 2.1 
9 
tests 
tests 
4.3 > > 
Thursday, 23 October 14
NO!tests code 
4.3> 3.7 > 
2.1 
10 
tests 
tests 
Thursday, 23 October 14
tests code 
2.1 == 2.1 
11 
Thursday, 23 October 14
NO! 
tests code 
2.1 == 2.1 12 
Thursday, 23 October 14
tests code 
2.0 < 2.1 
13 
Thursday, 23 October 14
NO! 
tests code 
2.0 < 2.1 14 
Thursday, 23 October 14
code 
tests 
1.0 <<< 
2.1 
15 
Thursday, 23 October 14
YEScode 
tests 
1.0 <<< 
2.1 
16 
Thursday, 23 October 14
1.0 ~> Simple 
E09E8C wolf 17 
Thursday, 23 October 14
what do I notice most? 
18 
Thursday, 23 October 14
Duplication! 
19 
Thursday, 23 October 14
Duplication 
usually indicates 
a missing 
abstraction 
20 
Thursday, 23 October 14
what do I notice now? 
21 
Thursday, 23 October 14
Duplication! 
22 
Thursday, 23 October 14
23 
Thursday, 23 October 14
what do I notice now? 
24 
Thursday, 23 October 14
Duplication! 
25 
Thursday, 23 October 14
26 
Thursday, 23 October 14
what do I notice now? 
27 
Thursday, 23 October 14
missing examples? 
28 
Thursday, 23 October 14
29 
Thursday, 23 October 14
what do I notice now? 
30 
Thursday, 23 October 14
better test names? 
31 
Thursday, 23 October 14
32 
Thursday, 23 October 14
what do I notice now? 
33 
Thursday, 23 October 14
different_identifier_style? 
differentIdentifierStyle? 
34 
Thursday, 23 October 14
that's ok! 
35 
Thursday, 23 October 14
what do I notice now? 
36 
Thursday, 23 October 14
duplication? 
37 
Thursday, 23 October 14
this is worse! 
38 
Thursday, 23 October 14
how about this? 
39 
Thursday, 23 October 14
40 
Thursday, 23 October 14
41 
1.0 
Specific ? 
21F1F3 alligator 
Thursday, 23 October 14
42 
! 
Thursday, 23 October 14
Specific ? 
43 
Thursday, 23 October 14
Specific :-) 
44 
Thursday, 23 October 14
Repetition ? 
45 
? 
Thursday, 23 October 14
Repetition can 
indicate a missing 
abstraction 
46 
Thursday, 23 October 14
Specific 
47 
Thursday, 23 October 14
Specific 
48 
Thursday, 23 October 14
49 
Thursday, 23 October 14
Recently Used List 
50 
Thursday, 23 October 14
e.g. Recent Files... 
51 
Thursday, 23 October 14
what do I notice? 
DE3BF3 buffalo 52 
Thursday, 23 October 14
Duplication! 
53 
Thursday, 23 October 14
What's left? 
red WTF? 
blue 
green 
54 
Thursday, 23 October 14
e.g. Files! 
55 
Thursday, 23 October 14
better! 
BAC947 snake 56 
Thursday, 23 October 14
better still 
57 
Thursday, 23 October 14
What do I notice now? 
58 
Thursday, 23 October 14
Duplication! 
59 
Thursday, 23 October 14
What does 
assertEquals() 
print when it fails? 
60 
Thursday, 23 October 14
61 
Thursday, 23 October 14
Do your 
diagnostics 
diagnose? 
62 
Thursday, 23 October 14
What 
diagnostic 
do you want? 
63 
Thursday, 23 October 14
make it pass 
64 
refactor 
write a test for 
new 
functionality 
write a test for 
new functionality 
ship it! 
Thursday, 23 October 14
make it pass 
65 
write a test for 
new 
functionality 
write a test for 
new functionality 
refactor 
ship it! 
Thursday, 23 October 14
make it pass 
66 
refactor 
write a test for 
new 
functionality 
write a test for 
new functionality 
ship it! 
refactor the 
diagnostic! 
Thursday, 23 October 14
make it pass 
67 
refactor 
write a test for 
new 
functionality 
write a test for 
new functionality 
ship it! 
refactor the 
diagnostic! 
Thursday, 23 October 14
How about this? 
68 
Thursday, 23 October 14
Make it so! 
69 
Thursday, 23 October 14
70 
Thursday, 23 October 14
71 
A 
B C 
D E F 
G 
external external 
Thursday, 23 October 14
72 
A 
B C 
tA 
mockist style 
B' C' 
D E F 
G 
Thursday, 23 October 14
mockist style 
73 
A 
B C 
D E F 
G 
tB 
D' E' 
C' 
Thursday, 23 October 14
mockist style 
74 
A 
B C 
D E F 
G 
G' 
F' 
B' 
tC 
Thursday, 23 October 14
mockist style 
code tests 
75 
Thursday, 23 October 14
classic style 
76 
A 
B C 
tA 
D E F 
G 
D' F' 
Thursday, 23 October 14
classic style 
code tests 
77 
Thursday, 23 October 14
the.law.of.demeter 
78 
Thursday, 23 October 14
79 
Thursday, 23 October 14
which is more 
important? 
the code or the 
tests? 
80 
Thursday, 23 October 14
both 
81 
Thursday, 23 October 14
You cannot determine 
the character or 
nature of a system 
within itself. 
Attempts to do so 
lead to confusion 
and disorder. 
82 
Thursday, 23 October 14
code and tests 
co-evolve 
83 
Thursday, 23 October 14
evolution is 
always co-evolution 
84 
Thursday, 23 October 14
85 
Thursday, 23 October 14
86 
Thursday, 23 October 14
87 
testing 
time 
Thursday, 23 October 14
88 
debugging 
time 
Thursday, 23 October 14
debugging = removing 
what you don't want 
89 
Thursday, 23 October 14
if you get rid of 
what you don't want, 
will you be left with 
what you do want? 
90 
Thursday, 23 October 14
91 ? Thursday, 23 October 14
92 
testing 
time 
Thursday, 23 October 14
93 
specification 
time 
Thursday, 23 October 14
94 
specific......... 
time 
Thursday, 23 October 14
Summary 
Burning calories - a metaphor for understandability 
Tests should be simple, linear, low complexity 
Tests should be specific 
Long_specific_test_names_are_ok 
Duplication usually means a missing abstraction 
Repetition can indicate a missing abstraction too 
Do your diagnostics diagnose? 
Custom assertions 
Don't cheat on test data - "String1" vs "red" 
Beware overusing Mockist style 
Code and tests co-evolve 
Test at the end is often debugging 
Test at the beginning as specification 
95 
Thursday, 23 October 14
96 
Thursday, 23 October 14
97 
Thursday, 23 October 14
98 
Thursday, 23 October 14
99 
Thursday, 23 October 14
code with no tests 
100 
FB75B3 
Thursday, 23 October 14
101 
Thursday, 23 October 14
Lesson ONE 
test code must be much 
simpler than the code it 
tests 
102 
Thursday, 23 October 14

More Related Content

PDF
Larry and Jen do Roman Numerals in C++
PDF
Atlantec - tdd lessons
PDF
Deep C
PDF
Design and Evolution of cyber-dojo
PDF
NorDevCon 2016 pair programming
PDF
Oslo Day of Docker Opening Keynote
PDF
Pair programming
PDF
Cyber-dojo: How to perform deliberate practice
Larry and Jen do Roman Numerals in C++
Atlantec - tdd lessons
Deep C
Design and Evolution of cyber-dojo
NorDevCon 2016 pair programming
Oslo Day of Docker Opening Keynote
Pair programming
Cyber-dojo: How to perform deliberate practice

More from Jon Jagger (6)

PDF
Lessons from Testing
PDF
Systems thinking
PDF
Kanban Push-me Pull-you
PDF
Some stuff about C++ and development
PDF
Systems Thinking
KEY
An Agile A to Z
Lessons from Testing
Systems thinking
Kanban Push-me Pull-you
Some stuff about C++ and development
Systems Thinking
An Agile A to Z
Ad

Recently uploaded (20)

PPTX
assetexplorer- product-overview - presentation
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Tech Workshop Escape Room Tech Workshop
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
MCP Security Tutorial - Beginner to Advanced
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
chapter 5 systemdesign2008.pptx for cimputer science students
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
assetexplorer- product-overview - presentation
Patient Appointment Booking in Odoo with online payment
iTop VPN Crack Latest Version Full Key 2025
Computer Software and OS of computer science of grade 11.pptx
Time Tracking Features That Teams and Organizations Actually Need
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Salesforce Agentforce AI Implementation.pdf
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Digital Systems & Binary Numbers (comprehensive )
Tech Workshop Escape Room Tech Workshop
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
MCP Security Tutorial - Beginner to Advanced
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Advanced SystemCare Ultimate Crack + Portable (2025)
GSA Content Generator Crack (2025 Latest)
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
chapter 5 systemdesign2008.pptx for cimputer science students
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Ad

lessons from testing