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

More Related Content

Similar to Lessons from Testing

Coderetreat @Sibiu 2012 08 18
Coderetreat @Sibiu 2012 08 18Coderetreat @Sibiu 2012 08 18
Coderetreat @Sibiu 2012 08 18
Adi Bolboaca
 

Similar to Lessons from Testing (20)

Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)
 
What is the actual life expectancy of your code?
What is the actual life expectancy of your code?What is the actual life expectancy of your code?
What is the actual life expectancy of your code?
 
CPP10 - Debugging
CPP10 - DebuggingCPP10 - Debugging
CPP10 - Debugging
 
TDD Walkthrough - Encryption
TDD Walkthrough - EncryptionTDD Walkthrough - Encryption
TDD Walkthrough - Encryption
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Coderetreat @Sibiu 2012 08 18
Coderetreat @Sibiu 2012 08 18Coderetreat @Sibiu 2012 08 18
Coderetreat @Sibiu 2012 08 18
 
Mastering Python lesson 3a
Mastering Python lesson 3aMastering Python lesson 3a
Mastering Python lesson 3a
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
Gmat
GmatGmat
Gmat
 
Test Driven Development of A Static Code Analyzer
Test Driven Development of A Static Code AnalyzerTest Driven Development of A Static Code Analyzer
Test Driven Development of A Static Code Analyzer
 
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
 
Code retreat @BMW Car IT
Code retreat @BMW Car ITCode retreat @BMW Car IT
Code retreat @BMW Car IT
 
Debug - MITX60012016-V005100
Debug - MITX60012016-V005100Debug - MITX60012016-V005100
Debug - MITX60012016-V005100
 
TDD a piccoli passi
TDD a piccoli passiTDD a piccoli passi
TDD a piccoli passi
 
Reverse engineering20151112
Reverse engineering20151112Reverse engineering20151112
Reverse engineering20151112
 
Exploit Research and Development Megaprimer: Win32 Egghunter
Exploit Research and Development Megaprimer: Win32 EgghunterExploit Research and Development Megaprimer: Win32 Egghunter
Exploit Research and Development Megaprimer: Win32 Egghunter
 
Mutation Testing - Ruby Edition
Mutation Testing - Ruby EditionMutation Testing - Ruby Edition
Mutation Testing - Ruby Edition
 
white-box-testing.pptx
white-box-testing.pptxwhite-box-testing.pptx
white-box-testing.pptx
 
Wtf per lineofcode
Wtf per lineofcodeWtf per lineofcode
Wtf per lineofcode
 

More from Jon Jagger (9)

NorDevCon 2016 pair programming
NorDevCon 2016 pair programmingNorDevCon 2016 pair programming
NorDevCon 2016 pair programming
 
Pair programming
Pair programmingPair programming
Pair programming
 
lessons from testing
lessons from testinglessons from testing
lessons from testing
 
Systems thinking
Systems thinkingSystems thinking
Systems thinking
 
Kanban Push-me Pull-you
Kanban Push-me Pull-youKanban Push-me Pull-you
Kanban Push-me Pull-you
 
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
 
Some stuff about C++ and development
Some stuff about C++ and developmentSome stuff about C++ and development
Some stuff about C++ and development
 
Systems Thinking
Systems ThinkingSystems Thinking
Systems Thinking
 
An Agile A to Z
An Agile A to ZAn Agile A to Z
An Agile A to Z
 

Recently uploaded

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Recently uploaded (20)

%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

Lessons from Testing