SlideShare a Scribd company logo
1 of 11
Personal Profile
Experience: 7+ Years in IT industry.
Education: MBA (Marketing) 2009 - 2011,
BSCS (Hons) 2000 - 2005
Skills Areas: PHP Frameworks, CMS &
Front-End Technologies
Cell #: 923009888545
Email: khurrammhd@gmail.com
Skype: Khurram645
Khurram Mahmood Bhatti
Software Lead at DatumSquare IT Services
Unit Testing
INTRODUCTION TO AUTOMATED TESTING AND UNIT TESTING
Agenda
 Types of Testing
 Unit Testing - What, Why & Who?
 Code Coverage
 Guideline for Unit Testing
 Demo by using PHP-Unit.
 Questions & Answers
Types of Testing
 White Box (or glass box) Testing
• Unit Testing
• Integration Testing
 Black Box Testing (Behavioral Testing)
• Incorrect or missing functions
• Interface, Initialization and termination errors
• Errors in data structures or external database access
• Behavior or performance errors
 Gray Box Testing ( Code + Behavior)
Unit Testing – What, Why & Who?
 What is Unit Testing?
• Test individual units/components of a software/system
• Validate each unit of the software performs as designed
• Source code is meeting requirement at its best.
 Why do we use it?
• Functional correctness and completeness
• Error handling
• Check input parameters (Input values)
• Correctness of return values (output data)
• Optimizing performance and algorithm
 Who does it?
• Typically written and run by software developers.
Coverage
 Statement Coverage (line of code)
 Branch Coverage (IF statements)
 Path Coverage (paths of program)
Path Coverage
Guidelines
 Unit tests must be small and fast
 Fully automated
 Simple to run
 Measure the tests
 Fix failing tests immediately
 Keep tests independent
 Name tests properly ( e.g testSaveData(),
testUpdateData() )
Unit Testing - Frameworks
 Examples:
 JUnit (Java)
 http://junit.org/junit4/
 NUnit (.NET)
 http://www.nunit.org/
 Doctest (Python)
 https://docs.python.org
 PHPUnit (PHP frameworks, e.g. - Codeigniter)
 https://phpunit.de/
 QUnit (JavaScript)
 https://qunitjs.com/
Demo
Calculator CalculatorTest
Questions & Answers

More Related Content

Similar to UNIT TESTING

Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...
Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...
Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...Turkish Testing Board
 
Using ML to Protect Customer Privacy by fmr Amazon Sr PM
Using ML to Protect Customer Privacy by fmr Amazon Sr PMUsing ML to Protect Customer Privacy by fmr Amazon Sr PM
Using ML to Protect Customer Privacy by fmr Amazon Sr PMProduct School
 
Test team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоTest team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоSigma Software
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaEdureka!
 
Creating a successful continuous testing environment by Eran Kinsbruner
Creating a successful continuous testing environment by Eran KinsbrunerCreating a successful continuous testing environment by Eran Kinsbruner
Creating a successful continuous testing environment by Eran KinsbrunerQA or the Highway
 
Sharath Resume
Sharath ResumeSharath Resume
Sharath ResumeSharath Ns
 
АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»
АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»
АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»GoQA
 
Quality Metrics: The Dirty Word in the Room
Quality Metrics: The Dirty Word in the RoomQuality Metrics: The Dirty Word in the Room
Quality Metrics: The Dirty Word in the RoomJosiah Renaudin
 
Software Testing Interview Questions & Answers | Edureka
Software Testing Interview Questions & Answers | EdurekaSoftware Testing Interview Questions & Answers | Edureka
Software Testing Interview Questions & Answers | EdurekaEdureka!
 
Test Automation with Gen AI_Final_Presentation
Test Automation with Gen AI_Final_PresentationTest Automation with Gen AI_Final_Presentation
Test Automation with Gen AI_Final_PresentationUiPathCommunity
 
Not Your Grandfather's Requirements-Based Testing Webinar – Robin Goldsmith, ...
Not Your Grandfather's Requirements-Based Testing Webinar – Robin Goldsmith, ...Not Your Grandfather's Requirements-Based Testing Webinar – Robin Goldsmith, ...
Not Your Grandfather's Requirements-Based Testing Webinar – Robin Goldsmith, ...XBOSoft
 
2 anton muzhailo - team development techniques you must know to be a valuab...
2   anton muzhailo - team development techniques you must know to be a valuab...2   anton muzhailo - team development techniques you must know to be a valuab...
2 anton muzhailo - team development techniques you must know to be a valuab...Ievgenii Katsan
 
Nancy Gupta_resume_Testing_3yrs
Nancy Gupta_resume_Testing_3yrsNancy Gupta_resume_Testing_3yrs
Nancy Gupta_resume_Testing_3yrsNancy Gupta
 
QA Training - Kanshe Infotech
QA Training - Kanshe InfotechQA Training - Kanshe Infotech
QA Training - Kanshe InfotechNaveen P
 
Preeti Sharma_2 years experience_QA_Manual and automation testing.txt
Preeti Sharma_2 years experience_QA_Manual and automation testing.txtPreeti Sharma_2 years experience_QA_Manual and automation testing.txt
Preeti Sharma_2 years experience_QA_Manual and automation testing.txtPreeti Sharma
 
Top 50 Software Testing Interview Questions & Answers | Edureka
Top 50 Software Testing Interview Questions & Answers | EdurekaTop 50 Software Testing Interview Questions & Answers | Edureka
Top 50 Software Testing Interview Questions & Answers | EdurekaEdureka!
 

Similar to UNIT TESTING (20)

Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...
Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...
Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...
 
Using ML to Protect Customer Privacy by fmr Amazon Sr PM
Using ML to Protect Customer Privacy by fmr Amazon Sr PMUsing ML to Protect Customer Privacy by fmr Amazon Sr PM
Using ML to Protect Customer Privacy by fmr Amazon Sr PM
 
Test team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоTest team dynamics, Антон Мужайло
Test team dynamics, Антон Мужайло
 
vinothraja_new
vinothraja_newvinothraja_new
vinothraja_new
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
 
Creating a successful continuous testing environment by Eran Kinsbruner
Creating a successful continuous testing environment by Eran KinsbrunerCreating a successful continuous testing environment by Eran Kinsbruner
Creating a successful continuous testing environment by Eran Kinsbruner
 
Sharath Resume
Sharath ResumeSharath Resume
Sharath Resume
 
АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»
АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»
АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»
 
Quality Metrics: The Dirty Word in the Room
Quality Metrics: The Dirty Word in the RoomQuality Metrics: The Dirty Word in the Room
Quality Metrics: The Dirty Word in the Room
 
Software Testing Interview Questions & Answers | Edureka
Software Testing Interview Questions & Answers | EdurekaSoftware Testing Interview Questions & Answers | Edureka
Software Testing Interview Questions & Answers | Edureka
 
Test Automation with Gen AI_Final_Presentation
Test Automation with Gen AI_Final_PresentationTest Automation with Gen AI_Final_Presentation
Test Automation with Gen AI_Final_Presentation
 
Software_Engineer
Software_EngineerSoftware_Engineer
Software_Engineer
 
Not Your Grandfather's Requirements-Based Testing Webinar – Robin Goldsmith, ...
Not Your Grandfather's Requirements-Based Testing Webinar – Robin Goldsmith, ...Not Your Grandfather's Requirements-Based Testing Webinar – Robin Goldsmith, ...
Not Your Grandfather's Requirements-Based Testing Webinar – Robin Goldsmith, ...
 
2 anton muzhailo - team development techniques you must know to be a valuab...
2   anton muzhailo - team development techniques you must know to be a valuab...2   anton muzhailo - team development techniques you must know to be a valuab...
2 anton muzhailo - team development techniques you must know to be a valuab...
 
Top Testing Tips
Top Testing TipsTop Testing Tips
Top Testing Tips
 
Nancy Gupta_resume_Testing_3yrs
Nancy Gupta_resume_Testing_3yrsNancy Gupta_resume_Testing_3yrs
Nancy Gupta_resume_Testing_3yrs
 
Debanjan mazumdar cv
Debanjan mazumdar cvDebanjan mazumdar cv
Debanjan mazumdar cv
 
QA Training - Kanshe Infotech
QA Training - Kanshe InfotechQA Training - Kanshe Infotech
QA Training - Kanshe Infotech
 
Preeti Sharma_2 years experience_QA_Manual and automation testing.txt
Preeti Sharma_2 years experience_QA_Manual and automation testing.txtPreeti Sharma_2 years experience_QA_Manual and automation testing.txt
Preeti Sharma_2 years experience_QA_Manual and automation testing.txt
 
Top 50 Software Testing Interview Questions & Answers | Edureka
Top 50 Software Testing Interview Questions & Answers | EdurekaTop 50 Software Testing Interview Questions & Answers | Edureka
Top 50 Software Testing Interview Questions & Answers | Edureka
 

UNIT TESTING

  • 1. Personal Profile Experience: 7+ Years in IT industry. Education: MBA (Marketing) 2009 - 2011, BSCS (Hons) 2000 - 2005 Skills Areas: PHP Frameworks, CMS & Front-End Technologies Cell #: 923009888545 Email: khurrammhd@gmail.com Skype: Khurram645 Khurram Mahmood Bhatti Software Lead at DatumSquare IT Services
  • 2. Unit Testing INTRODUCTION TO AUTOMATED TESTING AND UNIT TESTING
  • 3. Agenda  Types of Testing  Unit Testing - What, Why & Who?  Code Coverage  Guideline for Unit Testing  Demo by using PHP-Unit.  Questions & Answers
  • 4. Types of Testing  White Box (or glass box) Testing • Unit Testing • Integration Testing  Black Box Testing (Behavioral Testing) • Incorrect or missing functions • Interface, Initialization and termination errors • Errors in data structures or external database access • Behavior or performance errors  Gray Box Testing ( Code + Behavior)
  • 5. Unit Testing – What, Why & Who?  What is Unit Testing? • Test individual units/components of a software/system • Validate each unit of the software performs as designed • Source code is meeting requirement at its best.  Why do we use it? • Functional correctness and completeness • Error handling • Check input parameters (Input values) • Correctness of return values (output data) • Optimizing performance and algorithm  Who does it? • Typically written and run by software developers.
  • 6. Coverage  Statement Coverage (line of code)  Branch Coverage (IF statements)  Path Coverage (paths of program)
  • 8. Guidelines  Unit tests must be small and fast  Fully automated  Simple to run  Measure the tests  Fix failing tests immediately  Keep tests independent  Name tests properly ( e.g testSaveData(), testUpdateData() )
  • 9. Unit Testing - Frameworks  Examples:  JUnit (Java)  http://junit.org/junit4/  NUnit (.NET)  http://www.nunit.org/  Doctest (Python)  https://docs.python.org  PHPUnit (PHP frameworks, e.g. - Codeigniter)  https://phpunit.de/  QUnit (JavaScript)  https://qunitjs.com/