• The vicious circle
Agenda
• Break the loop • Getting the time • Mental Hacks (Using the
time wisely)
Slide 3
The vicious circle
Slide 4
What today is…
…is Tomorrow
No time to
Crazy regressions
unit test
& unexpected bugs
Slide 5
What today is…
…is Tomorrow
Lack of
No meaningful
practice
unit tests
Slide 6
Break the loop
Slide 7
Getting the time
Slide 8
Selling points
ARGUMENTS to convert
your boss a Unit Testing fan
%
Slide 9
Argument to get time
What is unit testing …in non techies words
Slide 10
Argument to get time:
Pyramid of testing: UI - Service - Unit
Slide 11
Argument to get time
The goal of unit testing is to sustain project growth by preventing software entropy
Slide 12
Argument to get time
Solid unit tested code increases time to market by minimizing regressions
Slide 13
Argument to get time
Writing unit tests today reduces the cost of the feature of tomorrow
Slide 14
Once you get the time… you need to be aware of…
Slide 15
Time stealers
SNEAKY things that
can fill your time
Slide 16
Time stealers
Time running unit tests
Slide 17
Time stealers
Time spent reading unit tests
Slide 18
Time stealers
Time spent rewriting tests
Slide 19
Time stealers Time dealing with false alarms
Slide 20
Writing the cool test
Slide 21
Step back
Set the concepts STRAIGHT
Slide 22
Concepts to get straight
Test Accuracy …what meaningful or cool actually stand for
Slide 23
Concepts to get straight Functionality Test Result Correct
Pass
Fail
! #
False Positive
Resistance to Refactoring
Broken
”
False Negative
!
Protection against regressions
Slide 24
Concepts to get straight
Pillars of Unit Testing
Slide 25
Concepts to get straight Resistance to refactoring
Focus
Focus
Maintainability
Protection against regressions
Choose
Choose
Fast Feedback
Slide 26
Mental hacks
WRITING the test that
helps
Slide 27
Mental hack: Black box testing
Test WHAT happens, not HOW it happens
Slide 28
Mental hack: Anti Example
Slide 29
Mental hack: Example
Slide 30
Mental hack: Test what matters
Focus on: important or complex code
Slide 31
Mental hack: Test what matters
Shopping Cart in E-Commerce Validations in Form Heavy pages
Slide 32
Mental hack: Test what matters Complex / Important
Complex or Important
Over complicated
Test
Split
No. of Dependencies or side effects
Trivial
Controllers
Ignore
Optional
Slide 33
Mental hacks
The STRUCTURE of the test that helps
Slide 34
Mental Hack: Test Anatomy
Given — When — Then
Slide 35
Mental Hack: Your test shall tell
2
Function — Scenario — Expected behavior
Slide 36
Mental Hack: Anti Example
Slide 37
Mental Hack: Example
Slide 38
Mental Hack: Your test aint’ wrong…
3
…your code is!
Slide 39
4
Mental Hack: Read the docs Get familiarized with your testing framework API
Slide 40
• The vicious circle
Recap
• Break the loop • Getting the time • Mental Hacks (Using the
time wisely)
Slide 41
Spoiler alerts
• WANT: a more scalable and flexible codebase
• PRICE: the beginner struggle, but keep going
• NEW YOU: you’ll write more testable code from start