SlideShare a Scribd company logo
1 of 17
Simple but useful
Unit Testing Techniques
Who Am I?
• Nir Tayeb - 25 years old
• Senior Full stack engineer at Tapingo
since November, 2014
• nir@tapingo.com, nir.tayeb@gmail.com
The situation
The company new senior developer (A.K.A
me) got a task to solve a big operational
issue in the core system
• The issue happened in one of our most
valuable venues
• The issue happened on specifics conditions
• Failing in fixing it right may ruin the whole
ordering system and affect all the rest of the
venues
• The last senior developer who tried to solve it
failed in Production
No unit-testings are available
That’s means I cannot make sure I don’t f*ck the whole ordering system
So for every change I made in the flow,
I’ve created a test to make sure it get the right results
Divide and Conquer
• The system is big and complex
• The function[s] I’ve wanted to tests are
depend on many external which are present
in cache/RDBMS/Mongo
• The function[s] I’ve wanted to tests are called
from different processes on different servers.
The main key to success in testing
is making your code more
MODULAR
Divide and Conquer
• Make the code more modular:
– Create function for bringing data
– Create function for verifying conditions
• In the test – patch those functions to get
specific “events”
Time Travel
• Datetime cannot be patched
• Instead of using datetime.now/utcnow
direct – make a function get_now
• In the test – patch this function return
value to the specific time you want
Testing in messaging
environment
• Separate the processing code to separate
function from the function which get the
message
• In the test – call to each processing
function one after one
Every time a bug is encountered by the
QA (good) or in Production (bad)
make a test which check the bug – so it
won’t happen never again!
Results
• In 2 weeks we solved the issue and it got
to production successfully
• About 99% of the code is already tested
(in the area I worked on)
• The code could easily refactored
Further readings
• Refactoring – Martin fowler

More Related Content

What's hot

The basics of UNIT testing
The basics of UNIT testing The basics of UNIT testing
The basics of UNIT testing David Tzemach
 
Spec By Example or How to teach people talk to each other
Spec By Example or How to teach people talk to each otherSpec By Example or How to teach people talk to each other
Spec By Example or How to teach people talk to each otherAndrey Rebrov
 
Mobile application testing
Mobile application testingMobile application testing
Mobile application testingparamadeep
 
Sevana QualTest
Sevana QualTestSevana QualTest
Sevana QualTestSevana Oü
 
Performance testing and j meter overview
Performance testing and j meter overviewPerformance testing and j meter overview
Performance testing and j meter overviewkrishna chaitanya
 
Test Automation Canvas
Test Automation CanvasTest Automation Canvas
Test Automation CanvasAndrey Rebrov
 
Extending Function Point Estimation for Testing MDM Applications
Extending Function Point Estimation for Testing MDM ApplicationsExtending Function Point Estimation for Testing MDM Applications
Extending Function Point Estimation for Testing MDM ApplicationsCognizant
 
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015Kim Herzig
 
How engineering practices help business
How engineering practices help businessHow engineering practices help business
How engineering practices help businessAndrey Rebrov
 
Regulated Software Testing - Griffin Jones - TISQA 2014
Regulated Software Testing  - Griffin Jones - TISQA 2014Regulated Software Testing  - Griffin Jones - TISQA 2014
Regulated Software Testing - Griffin Jones - TISQA 2014Griffin Jones
 
Automation in the Bug Flow - Machine Learning for Triaging and Tracing
Automation in the Bug Flow - Machine Learning for Triaging and TracingAutomation in the Bug Flow - Machine Learning for Triaging and Tracing
Automation in the Bug Flow - Machine Learning for Triaging and TracingMarkus Borg
 
Benefits of Unit Testing
Benefits of Unit TestingBenefits of Unit Testing
Benefits of Unit TestingBarkan Saeed
 
Agile performance testing
Agile performance testingAgile performance testing
Agile performance testingAndriy Melnyk
 
Kent Dyer Resume
Kent Dyer ResumeKent Dyer Resume
Kent Dyer ResumeKent Dyer
 

What's hot (19)

The basics of UNIT testing
The basics of UNIT testing The basics of UNIT testing
The basics of UNIT testing
 
QTest
QTest QTest
QTest
 
Spec By Example or How to teach people talk to each other
Spec By Example or How to teach people talk to each otherSpec By Example or How to teach people talk to each other
Spec By Example or How to teach people talk to each other
 
Mobile application testing
Mobile application testingMobile application testing
Mobile application testing
 
Performance testing
Performance testingPerformance testing
Performance testing
 
Sevana QualTest
Sevana QualTestSevana QualTest
Sevana QualTest
 
Performance testing and j meter overview
Performance testing and j meter overviewPerformance testing and j meter overview
Performance testing and j meter overview
 
Test Automation Canvas
Test Automation CanvasTest Automation Canvas
Test Automation Canvas
 
Extending Function Point Estimation for Testing MDM Applications
Extending Function Point Estimation for Testing MDM ApplicationsExtending Function Point Estimation for Testing MDM Applications
Extending Function Point Estimation for Testing MDM Applications
 
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
How engineering practices help business
How engineering practices help businessHow engineering practices help business
How engineering practices help business
 
Regulated Software Testing - Griffin Jones - TISQA 2014
Regulated Software Testing  - Griffin Jones - TISQA 2014Regulated Software Testing  - Griffin Jones - TISQA 2014
Regulated Software Testing - Griffin Jones - TISQA 2014
 
manual testing
manual testingmanual testing
manual testing
 
Automation in the Bug Flow - Machine Learning for Triaging and Tracing
Automation in the Bug Flow - Machine Learning for Triaging and TracingAutomation in the Bug Flow - Machine Learning for Triaging and Tracing
Automation in the Bug Flow - Machine Learning for Triaging and Tracing
 
Benefits of Unit Testing
Benefits of Unit TestingBenefits of Unit Testing
Benefits of Unit Testing
 
[Quang Nguyen] Performance Test in Best Practices
[Quang Nguyen] Performance Test in Best Practices[Quang Nguyen] Performance Test in Best Practices
[Quang Nguyen] Performance Test in Best Practices
 
Agile performance testing
Agile performance testingAgile performance testing
Agile performance testing
 
Kent Dyer Resume
Kent Dyer ResumeKent Dyer Resume
Kent Dyer Resume
 

Viewers also liked

Pitch deck
Pitch deckPitch deck
Pitch deckAli Amin
 
The Frictionless World Arrives
The Frictionless World ArrivesThe Frictionless World Arrives
The Frictionless World ArrivesRobert Scoble
 
Sequoia Capital Pitch Deck Template
Sequoia Capital Pitch Deck TemplateSequoia Capital Pitch Deck Template
Sequoia Capital Pitch Deck TemplateMalcolm Lewis
 
The slide deck we used to raise half a million dollars
The slide deck we used to raise half a million dollarsThe slide deck we used to raise half a million dollars
The slide deck we used to raise half a million dollarsBuffer
 

Viewers also liked (6)

Toyota 130601
Toyota 130601Toyota 130601
Toyota 130601
 
Pitch deck
Pitch deckPitch deck
Pitch deck
 
Credit Karma
Credit KarmaCredit Karma
Credit Karma
 
The Frictionless World Arrives
The Frictionless World ArrivesThe Frictionless World Arrives
The Frictionless World Arrives
 
Sequoia Capital Pitch Deck Template
Sequoia Capital Pitch Deck TemplateSequoia Capital Pitch Deck Template
Sequoia Capital Pitch Deck Template
 
The slide deck we used to raise half a million dollars
The slide deck we used to raise half a million dollarsThe slide deck we used to raise half a million dollars
The slide deck we used to raise half a million dollars
 

Similar to Simple but usefull unit tests

Agile Acceptance testing with Fitnesse
Agile Acceptance testing with FitnesseAgile Acceptance testing with Fitnesse
Agile Acceptance testing with FitnesseClareMcLennan
 
Alexander Podelko - Context-Driven Performance Testing
Alexander Podelko - Context-Driven Performance TestingAlexander Podelko - Context-Driven Performance Testing
Alexander Podelko - Context-Driven Performance TestingNeotys_Partner
 
Software testing regression testing
Software testing  regression testingSoftware testing  regression testing
Software testing regression testingGaneshKumarKanthiah
 
Architectural Testability Workshop for Test Academy Barcelona
Architectural Testability Workshop for Test Academy BarcelonaArchitectural Testability Workshop for Test Academy Barcelona
Architectural Testability Workshop for Test Academy BarcelonaAsh Winter
 
Testing strategies part -1
Testing strategies part -1Testing strategies part -1
Testing strategies part -1Divya Tiwari
 
Road to Continuous Delivery - Wix.com
Road to Continuous Delivery - Wix.comRoad to Continuous Delivery - Wix.com
Road to Continuous Delivery - Wix.comAviran Mordo
 
testing strategies and tactics
 testing strategies and tactics testing strategies and tactics
testing strategies and tacticsPreeti Mishra
 
Test Driven Development – What Works And What Doesn’t
Test Driven Development – What Works And What Doesn’t Test Driven Development – What Works And What Doesn’t
Test Driven Development – What Works And What Doesn’t Synerzip
 
Automated testing overview
Automated testing overviewAutomated testing overview
Automated testing overviewAlex Pop
 
V Model in Software Testing
V Model in Software TestingV Model in Software Testing
V Model in Software TestingAbdul Raheem
 
Agile Testing Introduction
Agile Testing IntroductionAgile Testing Introduction
Agile Testing IntroductionHai Tran Son
 
Automated testing san francisco oct 2013
Automated testing san francisco oct 2013Automated testing san francisco oct 2013
Automated testing san francisco oct 2013Solano Labs
 
Solano Labs presented at MassTLC's automated testing
Solano Labs presented at MassTLC's automated testingSolano Labs presented at MassTLC's automated testing
Solano Labs presented at MassTLC's automated testingMassTLC
 
Shorten Business Life Cycle Using DevOps
Shorten Business Life Cycle Using DevOpsShorten Business Life Cycle Using DevOps
Shorten Business Life Cycle Using DevOpsPerfecto Mobile
 
Performance Testing in the Agile Lifecycle
Performance Testing in the Agile LifecyclePerformance Testing in the Agile Lifecycle
Performance Testing in the Agile LifecycleLee Barnes
 

Similar to Simple but usefull unit tests (20)

Agile Acceptance testing with Fitnesse
Agile Acceptance testing with FitnesseAgile Acceptance testing with Fitnesse
Agile Acceptance testing with Fitnesse
 
Tdd
TddTdd
Tdd
 
NYC MeetUp 10.9
NYC MeetUp 10.9NYC MeetUp 10.9
NYC MeetUp 10.9
 
Presentation delex
Presentation delexPresentation delex
Presentation delex
 
Alexander Podelko - Context-Driven Performance Testing
Alexander Podelko - Context-Driven Performance TestingAlexander Podelko - Context-Driven Performance Testing
Alexander Podelko - Context-Driven Performance Testing
 
Software testing regression testing
Software testing  regression testingSoftware testing  regression testing
Software testing regression testing
 
Architectural Testability Workshop for Test Academy Barcelona
Architectural Testability Workshop for Test Academy BarcelonaArchitectural Testability Workshop for Test Academy Barcelona
Architectural Testability Workshop for Test Academy Barcelona
 
Testing strategies part -1
Testing strategies part -1Testing strategies part -1
Testing strategies part -1
 
Learn software testing
Learn software testingLearn software testing
Learn software testing
 
Road to Continuous Delivery - Wix.com
Road to Continuous Delivery - Wix.comRoad to Continuous Delivery - Wix.com
Road to Continuous Delivery - Wix.com
 
testing strategies and tactics
 testing strategies and tactics testing strategies and tactics
testing strategies and tactics
 
Test Driven Development – What Works And What Doesn’t
Test Driven Development – What Works And What Doesn’t Test Driven Development – What Works And What Doesn’t
Test Driven Development – What Works And What Doesn’t
 
Regression testing
Regression testingRegression testing
Regression testing
 
Automated testing overview
Automated testing overviewAutomated testing overview
Automated testing overview
 
V Model in Software Testing
V Model in Software TestingV Model in Software Testing
V Model in Software Testing
 
Agile Testing Introduction
Agile Testing IntroductionAgile Testing Introduction
Agile Testing Introduction
 
Automated testing san francisco oct 2013
Automated testing san francisco oct 2013Automated testing san francisco oct 2013
Automated testing san francisco oct 2013
 
Solano Labs presented at MassTLC's automated testing
Solano Labs presented at MassTLC's automated testingSolano Labs presented at MassTLC's automated testing
Solano Labs presented at MassTLC's automated testing
 
Shorten Business Life Cycle Using DevOps
Shorten Business Life Cycle Using DevOpsShorten Business Life Cycle Using DevOps
Shorten Business Life Cycle Using DevOps
 
Performance Testing in the Agile Lifecycle
Performance Testing in the Agile LifecyclePerformance Testing in the Agile Lifecycle
Performance Testing in the Agile Lifecycle
 

Simple but usefull unit tests

  • 1. Simple but useful Unit Testing Techniques
  • 2. Who Am I? • Nir Tayeb - 25 years old • Senior Full stack engineer at Tapingo since November, 2014 • nir@tapingo.com, nir.tayeb@gmail.com
  • 3. The situation The company new senior developer (A.K.A me) got a task to solve a big operational issue in the core system
  • 4. • The issue happened in one of our most valuable venues • The issue happened on specifics conditions • Failing in fixing it right may ruin the whole ordering system and affect all the rest of the venues • The last senior developer who tried to solve it failed in Production
  • 5. No unit-testings are available That’s means I cannot make sure I don’t f*ck the whole ordering system
  • 6. So for every change I made in the flow, I’ve created a test to make sure it get the right results
  • 7. Divide and Conquer • The system is big and complex • The function[s] I’ve wanted to tests are depend on many external which are present in cache/RDBMS/Mongo • The function[s] I’ve wanted to tests are called from different processes on different servers.
  • 8. The main key to success in testing is making your code more MODULAR
  • 9. Divide and Conquer • Make the code more modular: – Create function for bringing data – Create function for verifying conditions • In the test – patch those functions to get specific “events”
  • 10.
  • 11. Time Travel • Datetime cannot be patched • Instead of using datetime.now/utcnow direct – make a function get_now • In the test – patch this function return value to the specific time you want
  • 12.
  • 13. Testing in messaging environment • Separate the processing code to separate function from the function which get the message • In the test – call to each processing function one after one
  • 14.
  • 15. Every time a bug is encountered by the QA (good) or in Production (bad) make a test which check the bug – so it won’t happen never again!
  • 16. Results • In 2 weeks we solved the issue and it got to production successfully • About 99% of the code is already tested (in the area I worked on) • The code could easily refactored
  • 17. Further readings • Refactoring – Martin fowler