SlideShare a Scribd company logo
1 of 102
Download to read offline
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

More from Jon Jagger

Lessons from Testing
Lessons from TestingLessons from Testing
Lessons from TestingJon Jagger
 
Systems thinking
Systems thinkingSystems thinking
Systems thinkingJon Jagger
 
Kanban Push-me Pull-you
Kanban Push-me Pull-youKanban Push-me Pull-you
Kanban Push-me Pull-youJon Jagger
 
Some stuff about C++ and development
Some stuff about C++ and developmentSome stuff about C++ and development
Some stuff about C++ and developmentJon Jagger
 
Systems Thinking
Systems ThinkingSystems Thinking
Systems ThinkingJon Jagger
 
An Agile A to Z
An Agile A to ZAn Agile A to Z
An Agile A to ZJon Jagger
 

More from Jon Jagger (6)

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
 
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

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-...Steffen Staab
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
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 🔝✔️✔️Delhi Call girls
 
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 GoalsJhone kinadey
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
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 Modelsaagamshah0812
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Recently uploaded (20)

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-...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
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 🔝✔️✔️
 
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
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
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
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

lessons from testing