Testing: ¿what, how, why?
David Ródenas — @drpicox
@drpicox
What?
describe(‘calculator’, () => {

it(‘should do sums’, () => {
let calculator = new Calculator();
calculator.input(2);
calculator.plus();
calculator.input(4);
calculator.equal();
let result = calculator.get();
expect(result).toBe(6);
});
});
2
@drpicox
How?
• NUnit, MSTest, …— C#
• FUnit, FRUIT, FortUnit, …— Fortran
• JUnit, FitNesse, Mockito, …— Java
• Jasmine, Mocha, QUnit, …— Javascript
• Unittest, py.test, Nose, …— Python
• MiniTest, Test::Unit, RSpec, … — Ruby
• …
• Cucumber, Selenium, SpecFlow, …— Scenario
3
• What?
• How?
• Why?
why?
@drpicox
Weight cost
6
+- +-
Think Write Debug
+-
@drpicox
Weight cost
7
Think
+-
• Surrounding code
• API for the new code
• Understand new features
@drpicox
Weight cost
8
Write
+-
• Faster typist speed is: 150 wpm
• Moderate typist speed is: 35 wpm
• 400 line code may contain 1000
words ~ 30 minutes
@drpicox
Weight cost
9
Debug
+-
• Even if everything works well, we
have to verify that it is true
• Navigate to affected point
• Make sure that everything works
as expected, each time
• If it fails, stop and start looking for
problems…
@drpicox
Weight cost
10
+- +-
Think Write Debug
+-
@drpicox
Weight cost
11
+- +-
Think Write Debug
+-
@drpicox
Weight cost
12
+- +-
Think Write Debug
+-
@drpicox
Debug
• How many debug cases have you thrown away?
13
@drpicox
Think
• Would not it be great for thinking to give us the debug?

• All cases
• All features with all semantics
• Everything debugged
• Do not throw away debug cases
• New features does not break old one
• Safe refactors to accommodate new changes
14
what?
@drpicox
Types of bugs
16
Logic Wiring Visual
@drpicox
Types of bugs
17
Logic Wiring Visual
Detection
Diagnose
Correction
@drpicox
Types of bugs
18
Logic Wiring Visual
Detection HARD EASY TRIVIAL
Diagnose HARD MEDIUM EASY
Correction HARD MEDIUM EASY
@drpicox
Detection HARD MEDIUM EASY
Diagnose HARD MEDIUM EASY
Correction HARD MEDIUM EASY
Types of bugs
19
Logic Wiring Visual
It is hard!
Is it?
@drpicox
Types of testing
20
Logic
Wiring
Visual
each takes there are
whole system
subsystems
just classes
@drpicox
Types of testing
21
Logic
Wiring
Visual > 10s
< 1s
~1ms
each takes
few
many
lots
there are
end-to-end
functional
unit
known as
whole system
subsystems
just classes
@drpicox
Types of testing
22
Logic
Wiring
Visual > 10s
< 1s
~1ms
each takes
few
many
lots
there are
end-to-end
functional
unit
known as
whole system
subsystems
just classes
acceptance testing
bdd
tdd
@drpicox
Types of testing
23
Logic
Wiring
Visual > 10s
< 1s
~1ms
each takes
few
many
lots
there are
end-to-end
functional
unit
known as
whole system
subsystems
just classes
acceptance testing
bdd
tdd
@drpicox
Types of testing
24
Logic
Wiring
Visualwhole system
subsystems
just classes
Unit
End-
-to-End
Functional
SoftwareEngineers
QAEngineers
@drpicox
Unit Testing
• It test the most dangerous kind of bugs
• It is easy to write
• It is fast to execute
• It is from engineers to engineers
• It focus into features details
25
@drpicox
Unit Testing
• It test the most dangerous kind of bugs → Solves them
• It is easy to write → Write tens in few minutes
• It is fast to execute → Development cycle of seconds
• It is from engineers to engineers → It is the doc
• It focus into features details → Solve fast ambiguity
• IT IS THE MOST POWERFUL TYPE OF TESTING
26
@drpicox
Unit Test Everything!
27
2,4,8 Rule Game
http://embed.plnkr.co/N0eGMg
@drpicox
Unit Test Everything!
• Test coverage?
28
@drpicox
Unit Test Everything!
• Test coverage?
29
¿Are you sure that you want
to write a line of code that cannot be
justified with a test?
¿Do you want to
write useless code?
¿Do you want to
maintain more code
than necessary?
¿Do you want to
relay in your ability
to manual testing
all cases?
@drpicox
Unit Test Everything!
30
Serious Banking
http://embed.plnkr.co/veOMnl
🃏
@drpicox
Unit Test Everything?
31
Serious Banking
http://embed.plnkr.co/veOMnl
🃏
Sorry, not everything, we have frame problem.
(we can imagine infinite stupid things that can go wrong)
how?
@drpicox
TDD
33
• Has anyone tried to write tests after write the code?
@drpicox 34
1. You are not allowed to write any production code unless
it is to make a failing unit test pass.
2. You are not allowed to write any more of a unit test
than is sufficient to fail; and compilation failures are
failures.
3. You are not allowed to write any more production code
than is sufficient to pass the one failing unit test.
Rules
http://embed.plnkr.co/x4yKnp
TDD
@drpicox
TDD
35
• You can see it in the following Kata:
• The Bowling Game Kata
@drpicox
it(‘should…’)
36
• No side effects: for each test instantiate the whole
system
• Fast execution: you should instantiate only what you
need
• Repeatable: test must always give same results
@drpicox
new
37
Carnew
Engine
BrakesWheels
Doors
…new
new
• In this schema, each time that we need a car, it makes a
new instance of all its parts, even if we do not need
them.
~tens of instances
@drpicox
new
38
Workshopnew
Garage
Cars
Staff
…new
new
• What if we are working with a higher level?
…
~thousands of instances
@drpicox
new
39
new
Garages
…
new
new
• Or even higher?
~zillions of instances
Franchises
Holding
@drpicox
new
40
• Dependency injection to the rescue (I)
describe(‘car’, () => {

it(‘lock should lock doors’, () => {
let doors = new Doors();
let car = new Car(null, null, doors);
car.lock();
expect(car.canOpenDoors()).toBe(false);
});
});
@drpicox
new
41
• Dependency injection to the rescue (II)
describe(‘hello world’, () => {

it(‘it should say hi there!’, () => {
let helloWorld = new HelloWorld();
helloWorld.sayHello();
expect(???).toBe(‘hi there!’);
});
});
http://embed.plnkr.co/JxAOX7
@drpicox
new
42
• Dependency injection to the rescue (II)
describe(‘hello world’, () => {

it(‘it should say hi there!’, () => {
let console = jasmine.createSpyObj(‘console’, [‘log’]);
let helloWorld = new HelloWorld(console);
helloWorld.sayHello();
expect(console.log).toHaveBeenCalledWith(‘hi there!’);
});
});
http://embed.plnkr.co/vZyo7u
@drpicox 43
Summary
@drpicox
Sumary
• Testing helps you to understand better what you want to
encode
• Testing saves you from throwing tests away and from
precious debug time
• Focus in Unit Test (acceptance testing is also amazing)
• Do not try to test every case that you can imagine
• Make sure that all tests explains your code
44
@drpicox
Sumary
• and of course:
45
Write tests First!
@drpicox
Bibliography
46
• https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882
• https://www.amazon.com/Clean-Coder-Conduct-Professional-Programmers/dp/0137081073
• http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd
• http://butunclebob.com/ArticleS.UncleBob.SingletonVsJustCreateOne
• http://misko.hevery.com/2008/11/17/unified-theory-of-bugs/
• http://misko.hevery.com/2008/08/25/root-cause-of-singletons/
• http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/
• http://misko.hevery.com/code-reviewers-guide/
• http://misko.hevery.com/2008/10/21/dependency-injection-myth-reference-passing
• http://misko.hevery.com/2008/11/11/clean-code-talks-dependency-injection/
• http://butunclebob.com/
• http://misko.hevery.com/
• plnkr.co/users/drpicox
@drpicox
Bibliography
47
@drpicox
Thanks!
48
David Ródenas — @drpicox
Testing: ¿what, how, why?

More Related Content

PDF
(automatic) Testing: from business to university and back
PDF
Testing, Learning and Professionalism — 20171214
PDF
ES3-2020-05 Testing
PDF
TDD CrashCourse Part3: TDD Techniques
PDF
ES3-2020-P2 Bowling Game Kata
PDF
ReactJS for Programmers
PDF
TDD reloaded - JUGTAA 24 Ottobre 2012
PPTX
Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019
(automatic) Testing: from business to university and back
Testing, Learning and Professionalism — 20171214
ES3-2020-05 Testing
TDD CrashCourse Part3: TDD Techniques
ES3-2020-P2 Bowling Game Kata
ReactJS for Programmers
TDD reloaded - JUGTAA 24 Ottobre 2012
Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019

What's hot (20)

PDF
Unit Testing - The Whys, Whens and Hows
PPTX
VT.NET 20160411: An Intro to Test Driven Development (TDD)
PPTX
Test-Driven Development (TDD)
PPTX
TDD Training
PPTX
TDD & BDD
PDF
Unit testing legacy code
ODP
Agile analysis development
PPTX
Tdd & clean code
PPT
TDD And Refactoring
PDF
Test driven development - Zombie proof your code
PDF
Test Driven Development
PDF
TDD Flow: The Mantra in Action
PDF
Working Effectively with Legacy Code: Lessons in Practice
PPTX
Cpp Testing Techniques Tips and Tricks - Cpp Europe
PPTX
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PPTX
PHPUnit - Unit testing
PDF
Test-Tutorial
PPT
TDD (Test Driven Design)
PDF
An Introduction to Test Driven Development
DOCX
Test driven development and unit testing with examples in C++
Unit Testing - The Whys, Whens and Hows
VT.NET 20160411: An Intro to Test Driven Development (TDD)
Test-Driven Development (TDD)
TDD Training
TDD & BDD
Unit testing legacy code
Agile analysis development
Tdd & clean code
TDD And Refactoring
Test driven development - Zombie proof your code
Test Driven Development
TDD Flow: The Mantra in Action
Working Effectively with Legacy Code: Lessons in Practice
Cpp Testing Techniques Tips and Tricks - Cpp Europe
PVS-Studio. Static code analyzer. Windows/Linux, C/C++/C#. 2017
PHPUnit - Unit testing
Test-Tutorial
TDD (Test Driven Design)
An Introduction to Test Driven Development
Test driven development and unit testing with examples in C++
Ad

Viewers also liked (15)

PDF
Ericsson consumer lab-tv-media-2015
PDF
Консалтинговые услуги по управлению ассортиментом
PDF
Что делать, чтобы ваша компания существовала через 10 лет
PPTX
Creating a Habit of Giving with Collegians
PDF
The Autoimmune Puzzle
PPTX
Chapter Collaboration - National & Chapters Are NOT On Different Planets
PDF
Designing Conference Experiences That Matter To Your Audience​
PDF
Єгор Стефанович – E-Ukraine as Innovation Platform for Reforms
PPTX
Александр Зикунов "C чего начинать в e-commercе"
PPT
Tichenella spiralis
PPT
Opticalrotatory dispersion
PDF
Eight Reasons to be a Cisco Select Certified Partner
PPTX
Insights into the Mobile Internet in Africa
PPT
Fairness cream
PDF
Санаторий Источник здоровья - новая версия
Ericsson consumer lab-tv-media-2015
Консалтинговые услуги по управлению ассортиментом
Что делать, чтобы ваша компания существовала через 10 лет
Creating a Habit of Giving with Collegians
The Autoimmune Puzzle
Chapter Collaboration - National & Chapters Are NOT On Different Planets
Designing Conference Experiences That Matter To Your Audience​
Єгор Стефанович – E-Ukraine as Innovation Platform for Reforms
Александр Зикунов "C чего начинать в e-commercе"
Tichenella spiralis
Opticalrotatory dispersion
Eight Reasons to be a Cisco Select Certified Partner
Insights into the Mobile Internet in Africa
Fairness cream
Санаторий Источник здоровья - новая версия
Ad

Similar to Testing: ¿what, how, why? (20)

PPTX
PuppetConf 2017: Test First Approach for Puppet on Windows- Miro Sommer, Hiscox
PDF
Mapping Detection Coverage
PDF
How to write clean & testable code without losing your mind
PDF
Automate Thyself
PDF
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
PDF
Test driven development
PDF
Python testing like a pro by Keith Yang
PDF
Никита Галкин "Testing in Frontend World"
PDF
Declarative benchmarking of cassandra and it's data models
PDF
Testing automaton
PDF
Testing Automaton - CFSummit 2016
PDF
Testing in FrontEnd World by Nikita Galkin
PDF
Sista: Improving Cog’s JIT performance
PDF
Everything as a Code / Александр Тарасов (Одноклассники)
PDF
Everything as a code
PDF
What’s eating python performance
PDF
Keynote AST 2016
PDF
Remote iOS Devices Server – Scaling iOS
PDF
BarcelonaJUG2016: walkmod: how to run and design code transformations
PPTX
Java Micro-Benchmarking
PuppetConf 2017: Test First Approach for Puppet on Windows- Miro Sommer, Hiscox
Mapping Detection Coverage
How to write clean & testable code without losing your mind
Automate Thyself
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Test driven development
Python testing like a pro by Keith Yang
Никита Галкин "Testing in Frontend World"
Declarative benchmarking of cassandra and it's data models
Testing automaton
Testing Automaton - CFSummit 2016
Testing in FrontEnd World by Nikita Galkin
Sista: Improving Cog’s JIT performance
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a code
What’s eating python performance
Keynote AST 2016
Remote iOS Devices Server – Scaling iOS
BarcelonaJUG2016: walkmod: how to run and design code transformations
Java Micro-Benchmarking

More from David Rodenas (20)

PDF
TDD CrashCourse Part2: TDD
PDF
TDD CrashCourse Part1: Testing
PDF
TDD CrashCourse Part5: Testing Techniques
PDF
TDD CrashCourse Part4: Improving Testing
PDF
Be professional: We Rule the World
PDF
ES3-2020-P3 TDD Calculator
PDF
ES3-2020-07 Testing techniques
PDF
ES3-2020-06 Test Driven Development (TDD)
PDF
Vespres
PDF
Faster web pages
PDF
Redux for ReactJS Programmers
PDF
Basic Tutorial of React for Programmers
PDF
Introduction to web programming for java and c# programmers by @drpicox
PPTX
From high school to university and work
PDF
Modules in angular 2.0 beta.1
PDF
Freelance i Enginyeria
PDF
Angular 1.X Community and API Decissions
PDF
JS and patterns
PDF
MVS: An angular MVC
PDF
Mvc - Model: the great forgotten
TDD CrashCourse Part2: TDD
TDD CrashCourse Part1: Testing
TDD CrashCourse Part5: Testing Techniques
TDD CrashCourse Part4: Improving Testing
Be professional: We Rule the World
ES3-2020-P3 TDD Calculator
ES3-2020-07 Testing techniques
ES3-2020-06 Test Driven Development (TDD)
Vespres
Faster web pages
Redux for ReactJS Programmers
Basic Tutorial of React for Programmers
Introduction to web programming for java and c# programmers by @drpicox
From high school to university and work
Modules in angular 2.0 beta.1
Freelance i Enginyeria
Angular 1.X Community and API Decissions
JS and patterns
MVS: An angular MVC
Mvc - Model: the great forgotten

Recently uploaded (20)

PPTX
Lecture 5 Software Requirement Engineering
PPTX
Full-Stack Developer Courses That Actually Land You Jobs
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
CCleaner 6.39.11548 Crack 2025 License Key
PPTX
Computer Software - Technology and Livelihood Education
PPTX
Introduction to Windows Operating System
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
Cybersecurity: Protecting the Digital World
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PDF
Guide to Food Delivery App Development.pdf
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PDF
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
PDF
E-Commerce Website Development Companyin india
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
PPTX
Tech Workshop Escape Room Tech Workshop
Lecture 5 Software Requirement Engineering
Full-Stack Developer Courses That Actually Land You Jobs
Wondershare Recoverit Full Crack New Version (Latest 2025)
DNT Brochure 2025 – ISV Solutions @ D365
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
CCleaner 6.39.11548 Crack 2025 License Key
Computer Software - Technology and Livelihood Education
Introduction to Windows Operating System
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Cybersecurity: Protecting the Digital World
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Guide to Food Delivery App Development.pdf
How Tridens DevSecOps Ensures Compliance, Security, and Agility
Topaz Photo AI Crack New Download (Latest 2025)
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
E-Commerce Website Development Companyin india
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
Tech Workshop Escape Room Tech Workshop

Testing: ¿what, how, why?