05 Testing
Enginyeria del Software 3
1
@drpicox — 2020
–Edsger W. Dijkstra 1969
“Testing shows the presence,
not the absence of bugs”
2
What is a test?
• REQUIREMENT: The calculator adds two numbers

• VERIFICATION:

• Turn on the calculator

• Write 2

• Press the plus sign

• Write 4

• Press equal

• The display should show 6
3
What is a test?
test('add two numbers', () => {
let calculator = new Calculator();
calculator.input(2);
calculator.plus();
calculator.input(4);
calculator.equal();
let result = calculator.get();
expect(result).toBe(6);
});
4
What to test?
• The requirements, or business rules
5
What to test?
• How many cases has the addition case?

• Two 32 bit inputs



232 x 232 = 18.446.744.073.709.551.616 cases

• If it takes 1 ms each case, we need 600 milion years
6
What to test?
• Which cases are relevant?

• The ones defined by requirements

• The minimal ones possible

• The most relevant ones

• The most easy to understand by a human
7
Why test?
// Pre: 0 ≤ left ≤ right ≤ vec.length
function posMin(vec, left, right) {
let pos = left;
for (let i = left + 1; i <= right; i++) {
if (vec[i] < vec[pos]) pos = i;
}
return pos;
}
// Post: returns pos ∧
// ∧ left ≤ pos ≤ right ∧
// ∧ vec[pos] = min(vec[left … right])
8
Before testing was
mainstream academia
tried verification. It was
not useful enough.
Why test?
• Were we loose the time when we are developing?
9
+- +-
Think Write Debug
+-
Think carefule before go to
the next slide. Which one
is the one in which you
invest more time?
Why test?
• The reality.
10
+- +-
Think Write Debug
+-
Think again (probably). If you do
not do testing you loose a looot
of time of debugging. There is no
proud on debugging skills, they
are useless when doing testing.
And writing, is so fast.
Why test?
• Our objective.
11
+- +-
Think Write Debug
+-
Testing first means think
more and caching bugs
earlier. Caching bugs
earlier means less debug.
Why to test?
• We know for sure that each scenario is working.

• 2 + 4 = [6]
• 2 + 4 + 5 = [11]
• 2 x 4 = [8]
• 2 x 4 x 5 = [40]
• 2 + 3 x 4 = [14]
• ...
12
Why to test?
• Trust
13
There is a button that
when I press it, I know that
everything works.
Why to test?
• Speed
14
Without Testing With Testing
Testing/TDD seems slow in
the beginning, but it is an
illusion, test nothing is
quickly more time-
consuming.
Why to test?
• Better design
15
Because we are confident
in changes, we can
upgrade the design under
demand. We do not need
to advance unnecessary
design complexity.
Why Testing?
• Automatic requirement/business rules verification

• Reduce debug time

• You know that every scenario works

• Trust

• Speed

• Better design

• LIVE DOCUMENTATION
16
And of course, tests are
documentation that never
stale.
History of Testing
17
18
“The growth of Software Testing”- ACM June 1988 D.Gelperin, B.Hetzel
1957
1979
1983
1988
Debugging
Demonstration
Destruction
Evaluation
Prevention
mixing construction and debugging
making sure that software satisfies its specification
detecting implementation faults
detecting requirements, design & implementation faults
preventing requirements, design & implementation faults
Early History of Testing
19
http://wiki.c2.com/?TenYearsOfTestDrivenDevelopment
1994
1999
2002
Beginning of new Era
xUnit
Extreme Programming
Framework Integrated Test
Test Driven Development
Ward Cunningham writes in one day a test runner
Kent Beck writes first version of SUnit (Testing Framework)
“Extreme Programming Explained: Embrace Change” - Kent Beck
Ward Cunningham writes first tool for test running
“Test Driven Development By Example” - Kent Beck
1989
Modern History of Testing
20
In 2002, fit, Framework
Integrated Test, was able to
execute tests from actual
documentation.
21
Example of a table executed
by Test.
Summary
• Testing does not ensure the absence of bugs

• Tests are driven by requirments and business rules

• Only test what is relevant, not everything

• Tests Improves quality and confidence

• It is live documentation

• Test is not new, and some great advances have 2 decades
22
Homework
• http://www.butunclebob.com/
ArticleS.UncleBob.TheThreeRulesOfTdd

• https://david-rodenas.com/blog/2020/03/06/everyone-
knows-how-to-do-great-testing.html
23

More Related Content

PDF
TDD CrashCourse Part1: Testing
PDF
TDD CrashCourse Part3: TDD Techniques
PDF
Testing, Learning and Professionalism — 20171214
PDF
ES3-2020-P2 Bowling Game Kata
PDF
Testing: ¿what, how, why?
PDF
TDD CrashCourse Part5: Testing Techniques
PPTX
VT.NET 20160411: An Intro to Test Driven Development (TDD)
PDF
Test Driven Development
TDD CrashCourse Part1: Testing
TDD CrashCourse Part3: TDD Techniques
Testing, Learning and Professionalism — 20171214
ES3-2020-P2 Bowling Game Kata
Testing: ¿what, how, why?
TDD CrashCourse Part5: Testing Techniques
VT.NET 20160411: An Intro to Test Driven Development (TDD)
Test Driven Development

What's hot (20)

PDF
TDD CrashCourse Part2: TDD
PDF
TDD and Simple Design Workshop - Session 1 - March 2019
PDF
TDD reloaded - JUGTAA 24 Ottobre 2012
PPTX
Test-Driven Development (TDD)
PDF
Unit testing legacy code
PPTX
TDD & BDD
PPTX
PHPUnit - Unit testing
PDF
iOS Test-Driven Development
PDF
Test driven development - Zombie proof your code
PPT
TDD And Refactoring
PPTX
TDD with RSpec
PPT
Google test training
PDF
TDD Flow: The Mantra in Action
PPT
Test Driven Development
PPT
TDD (Test Driven Design)
KEY
TDD refresher
PPTX
TDD - Test Driven Development
PPT
Test Driven Development
PPTX
Working Effectively with Legacy Code
TDD CrashCourse Part2: TDD
TDD and Simple Design Workshop - Session 1 - March 2019
TDD reloaded - JUGTAA 24 Ottobre 2012
Test-Driven Development (TDD)
Unit testing legacy code
TDD & BDD
PHPUnit - Unit testing
iOS Test-Driven Development
Test driven development - Zombie proof your code
TDD And Refactoring
TDD with RSpec
Google test training
TDD Flow: The Mantra in Action
Test Driven Development
TDD (Test Driven Design)
TDD refresher
TDD - Test Driven Development
Test Driven Development
Working Effectively with Legacy Code
Ad

Similar to ES3-2020-05 Testing (20)

PDF
Keynote AST 2016
PPTX
Test driven development
PDF
TDD and Related Techniques for Non Developers (2012)
PPTX
First steps in testing analytics: Does test code quality matter?
PPTX
Software Testing, Everyone's responsibility
PPTX
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
PDF
Dev buchan 30 proven tips
PPTX
TDD: seriously, try it! 
PPTX
An Introduction To Software Development - Test Driven Development, Part 1
PDF
Introduzione allo Unit Testing
PPTX
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
PPTX
BTD2015 - Your Place In DevTOps is Finding Solutions - Not Just Bugs!
PPTX
Write tests, please
PDF
(automatic) Testing: from business to university and back
PPTX
Tdd is not about testing (OOP)
ODP
What is xp
PPTX
SAST, fight against potential vulnerabilities
PDF
Achieve Intelligent Test Execution: Strategies for Streamlining Regression Te...
PDF
I am afraid of no test! The power of BDD
PPT
Test Driven
Keynote AST 2016
Test driven development
TDD and Related Techniques for Non Developers (2012)
First steps in testing analytics: Does test code quality matter?
Software Testing, Everyone's responsibility
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
Dev buchan 30 proven tips
TDD: seriously, try it! 
An Introduction To Software Development - Test Driven Development, Part 1
Introduzione allo Unit Testing
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
BTD2015 - Your Place In DevTOps is Finding Solutions - Not Just Bugs!
Write tests, please
(automatic) Testing: from business to university and back
Tdd is not about testing (OOP)
What is xp
SAST, fight against potential vulnerabilities
Achieve Intelligent Test Execution: Strategies for Streamlining Regression Te...
I am afraid of no test! The power of BDD
Test Driven
Ad

More from David Rodenas (18)

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
ReactJS for Programmers
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 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)
ReactJS for Programmers
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
Module1.pptxrjkeieuekwkwoowkemehehehrjrjrj
PPTX
Micro1New.ppt.pptx the mai themes of micfrobiology
PPTX
Environmental studies, Moudle 3-Environmental Pollution.pptx
PDF
MLpara ingenieira CIVIL, meca Y AMBIENTAL
PPT
UNIT-I Machine Learning Essentials for 2nd years
PDF
Designing Fault-Tolerant Architectures for Resilient Oracle Cloud ERP and HCM...
PPTX
WN UNIT-II CH4_MKaruna_BapatlaEngineeringCollege.pptx
PPTX
Solar energy pdf of gitam songa hemant k
PDF
Beginners-Guide-to-Artificial-Intelligence.pdf
PDF
20250617 - IR - Global Guide for HR - 51 pages.pdf
PDF
Cryptography and Network Security-Module-I.pdf
PPTX
Design ,Art Across Digital Realities and eXtended Reality
PPTX
Environmental studies, Moudle 3-Environmental Pollution.pptx
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PPTX
CT Generations and Image Reconstruction methods
PDF
Mechanics of materials week 2 rajeshwari
PDF
Unit I -OPERATING SYSTEMS_SRM_KATTANKULATHUR.pptx.pdf
PPTX
MAD Unit - 3 User Interface and Data Management (Diploma IT)
PDF
[jvmmeetup] next-gen integration with apache camel and quarkus.pdf
PDF
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL
Module1.pptxrjkeieuekwkwoowkemehehehrjrjrj
Micro1New.ppt.pptx the mai themes of micfrobiology
Environmental studies, Moudle 3-Environmental Pollution.pptx
MLpara ingenieira CIVIL, meca Y AMBIENTAL
UNIT-I Machine Learning Essentials for 2nd years
Designing Fault-Tolerant Architectures for Resilient Oracle Cloud ERP and HCM...
WN UNIT-II CH4_MKaruna_BapatlaEngineeringCollege.pptx
Solar energy pdf of gitam songa hemant k
Beginners-Guide-to-Artificial-Intelligence.pdf
20250617 - IR - Global Guide for HR - 51 pages.pdf
Cryptography and Network Security-Module-I.pdf
Design ,Art Across Digital Realities and eXtended Reality
Environmental studies, Moudle 3-Environmental Pollution.pptx
August -2025_Top10 Read_Articles_ijait.pdf
CT Generations and Image Reconstruction methods
Mechanics of materials week 2 rajeshwari
Unit I -OPERATING SYSTEMS_SRM_KATTANKULATHUR.pptx.pdf
MAD Unit - 3 User Interface and Data Management (Diploma IT)
[jvmmeetup] next-gen integration with apache camel and quarkus.pdf
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL

ES3-2020-05 Testing

  • 1. 05 Testing Enginyeria del Software 3 1 @drpicox — 2020
  • 2. –Edsger W. Dijkstra 1969 “Testing shows the presence, not the absence of bugs” 2
  • 3. What is a test? • REQUIREMENT: The calculator adds two numbers • VERIFICATION: • Turn on the calculator • Write 2 • Press the plus sign • Write 4 • Press equal • The display should show 6 3
  • 4. What is a test? test('add two numbers', () => { let calculator = new Calculator(); calculator.input(2); calculator.plus(); calculator.input(4); calculator.equal(); let result = calculator.get(); expect(result).toBe(6); }); 4
  • 5. What to test? • The requirements, or business rules 5
  • 6. What to test? • How many cases has the addition case? • Two 32 bit inputs
 
 232 x 232 = 18.446.744.073.709.551.616 cases
 • If it takes 1 ms each case, we need 600 milion years 6
  • 7. What to test? • Which cases are relevant? • The ones defined by requirements • The minimal ones possible • The most relevant ones • The most easy to understand by a human 7
  • 8. Why test? // Pre: 0 ≤ left ≤ right ≤ vec.length function posMin(vec, left, right) { let pos = left; for (let i = left + 1; i <= right; i++) { if (vec[i] < vec[pos]) pos = i; } return pos; } // Post: returns pos ∧ // ∧ left ≤ pos ≤ right ∧ // ∧ vec[pos] = min(vec[left … right]) 8 Before testing was mainstream academia tried verification. It was not useful enough.
  • 9. Why test? • Were we loose the time when we are developing? 9 +- +- Think Write Debug +- Think carefule before go to the next slide. Which one is the one in which you invest more time?
  • 10. Why test? • The reality. 10 +- +- Think Write Debug +- Think again (probably). If you do not do testing you loose a looot of time of debugging. There is no proud on debugging skills, they are useless when doing testing. And writing, is so fast.
  • 11. Why test? • Our objective. 11 +- +- Think Write Debug +- Testing first means think more and caching bugs earlier. Caching bugs earlier means less debug.
  • 12. Why to test? • We know for sure that each scenario is working.
 • 2 + 4 = [6] • 2 + 4 + 5 = [11] • 2 x 4 = [8] • 2 x 4 x 5 = [40] • 2 + 3 x 4 = [14] • ... 12
  • 13. Why to test? • Trust 13 There is a button that when I press it, I know that everything works.
  • 14. Why to test? • Speed 14 Without Testing With Testing Testing/TDD seems slow in the beginning, but it is an illusion, test nothing is quickly more time- consuming.
  • 15. Why to test? • Better design 15 Because we are confident in changes, we can upgrade the design under demand. We do not need to advance unnecessary design complexity.
  • 16. Why Testing? • Automatic requirement/business rules verification • Reduce debug time • You know that every scenario works • Trust • Speed • Better design • LIVE DOCUMENTATION 16 And of course, tests are documentation that never stale.
  • 18. 18 “The growth of Software Testing”- ACM June 1988 D.Gelperin, B.Hetzel 1957 1979 1983 1988 Debugging Demonstration Destruction Evaluation Prevention mixing construction and debugging making sure that software satisfies its specification detecting implementation faults detecting requirements, design & implementation faults preventing requirements, design & implementation faults Early History of Testing
  • 19. 19 http://wiki.c2.com/?TenYearsOfTestDrivenDevelopment 1994 1999 2002 Beginning of new Era xUnit Extreme Programming Framework Integrated Test Test Driven Development Ward Cunningham writes in one day a test runner Kent Beck writes first version of SUnit (Testing Framework) “Extreme Programming Explained: Embrace Change” - Kent Beck Ward Cunningham writes first tool for test running “Test Driven Development By Example” - Kent Beck 1989 Modern History of Testing
  • 20. 20 In 2002, fit, Framework Integrated Test, was able to execute tests from actual documentation.
  • 21. 21 Example of a table executed by Test.
  • 22. Summary • Testing does not ensure the absence of bugs • Tests are driven by requirments and business rules • Only test what is relevant, not everything • Tests Improves quality and confidence • It is live documentation • Test is not new, and some great advances have 2 decades 22