SlideShare a Scribd company logo
Introduction of Unit Test to
Management and Business
August, 2012
Wei Li
”To err is human;
to forgive, divine.”
Alexander Pope
 Developer Test
– Unit Test
– Integration Test
– Regression Test
 QA Test
– Integration Test
– Regression Test
– Performance Test
– Stress Test
 Customer/User Test
– Acceptability Test
– Usability Test
Many Tests in the Life Cycle of Software Development
What is Unit Test
 Self checking or validation to ensure the code work as expected
 Developer’s test
 Part of construction cycle
 Foundation of all other tests
Where Does Unit Test Fit in Life Cycle?
 Requirement gathering
 Business Design
 Technical Design
– Architecture Design
– Technical Design
 Construction
– Code and Unit Test
 QA Test
 Performance Test
 User Test
Unit Test Is Not
 QA test
 Customer/user test
Why?
 What? Write code to test code?
 No! I don’t have time for it!
Benefits of Unit Test – Instant Feedback
 Unit test provides the earliest opportunity to identify and fix a defect
 The earlier an error is found, the less expensive it is to fix it
 Performed before components are integrated together
 Force the developer to write clean and testable code – which leads
to less complexity and better design
 If your code is hard to be tested, how can it be easily used,
maintained and extended?
Benefits of Unit Test – Write Testable Code
Benefits of Unit Test – Establish Safety Net in the Lifecycle
 Can be used as part of regression test suite
 Provide the green light to refactor old code and make changes
Benefits of Unit Test – Good Way to Work with Legacy/Existing Code
 Write unit test to get started understanding legacy code and system
Benefits of Unit Test – Excellent Way to Learn New Language and API
 Write unit test cases to learn and try new API
 The unit test cases can become reusable knowledge base
Benefits of Unit Test – Excellent Way to Report a Defect
 Write a unit test case to report a defect or a bug in the system
 Run the same test to verify the defect is fixed
Benefits of Unit Test - Reusability
 Write once run forever – reusable and repeatable
 Save time long term in the life cycle
 Give new team member a good jump start
Unit Test Practice
 Planning and estimation - account for the construction time
for unit test
 Code a little and unit test a little - repeat the cycle until the
construction is done
 Part of the code review process
 Run unit test when trouble shooting issues
 Run unit test whenever a change is made
 Run unit test whenever is needed
 Enjoy the results
 Our old friend JUnit is still our best friend
– No new wheel was reinvented
– De facto tool
– Familiarity to most developers
Unit Test Practice
 Use a separate unit test project
– Only contain unit test related Java code but test code in other projects
– Run locally and not deployed to application server
 Won’t be part of the deployable to application server
– Freedom to write more unit tests
– Save time in testing (no build and deployment)
Unit Test Practice
 Unit test coverage – the thorough the better
Unit Test Practice
 Just do it and it will become a habit
 You will find out you actually have time to write unit test code
 You will find out you actually enjoy doing it
Unit Test Practice
Test Driven/Test First Methodology
 Write a test case for a new functionality
 Run the test and it fails
 Write just enough code to make the test pass
 Run the test and it passes
 Refactor the code to make it better
 Repeat the test
 Repeat the cycle
Continuous Integration
 Get the latest version of the code from source control system
 Build/compile the code
 Run all unit test cases
 Publish the build and test results
 Notify the development team for any failure
 Repeat the process periodically, for example, once every hour
”To err is developer;
to catch early, unit
test.”
Ad

More Related Content

What's hot (20)

Agile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated TestingAgile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated Testing
Dimitri Ponomareff
 
Agile testing - Testing From Day 1
Agile testing - Testing From Day 1Agile testing - Testing From Day 1
Agile testing - Testing From Day 1
Kaizenko
 
ATA CP-MAT program highlights
ATA CP-MAT program highlightsATA CP-MAT program highlights
ATA CP-MAT program highlights
Agile Testing Alliance
 
#BugATAhon2016 #WhoHasKeeda
#BugATAhon2016 #WhoHasKeeda#BugATAhon2016 #WhoHasKeeda
#BugATAhon2016 #WhoHasKeeda
Agile Testing Alliance
 
Selenium Certification
Selenium CertificationSelenium Certification
Selenium Certification
Vskills
 
CP-SAT - Certified Professional Selenium Automation Testing
CP-SAT - Certified Professional Selenium Automation TestingCP-SAT - Certified Professional Selenium Automation Testing
CP-SAT - Certified Professional Selenium Automation Testing
Agile Testing Alliance
 
Testing automation in agile environment
Testing automation in agile environmentTesting automation in agile environment
Testing automation in agile environment
Perfecto Mobile
 
Introduction to Test Automation - Technology and Tools
Introduction to Test Automation - Technology and ToolsIntroduction to Test Automation - Technology and Tools
Introduction to Test Automation - Technology and Tools
KMS Technology
 
Rakuten presentation qa_night
Rakuten presentation qa_nightRakuten presentation qa_night
Rakuten presentation qa_night
Yusuke Nakamura
 
7 Deadly Sins of Agile Software Test Automation
7 Deadly Sins of Agile Software Test Automation7 Deadly Sins of Agile Software Test Automation
7 Deadly Sins of Agile Software Test Automation
Adrian Smith
 
Large-Scale Agile Test Automation Strategies in Practice
Large-Scale Agile Test Automation Strategies in PracticeLarge-Scale Agile Test Automation Strategies in Practice
Large-Scale Agile Test Automation Strategies in Practice
TechWell
 
Agile test tools
Agile test toolsAgile test tools
Agile test tools
Agile Partner S.A.
 
Test automation - What? Why? How?
Test automation - What? Why? How?Test automation - What? Why? How?
Test automation - What? Why? How?
Anand Bagmar
 
Agile tour ncr test360_degree - agile testing on steroids
Agile tour ncr test360_degree - agile testing on steroidsAgile tour ncr test360_degree - agile testing on steroids
Agile tour ncr test360_degree - agile testing on steroids
Vipul Gupta
 
Agile Testing - presentation for Agile User Group
Agile Testing - presentation for Agile User GroupAgile Testing - presentation for Agile User Group
Agile Testing - presentation for Agile User Group
suwalki24.pl
 
The DevOps Dance - Shift Left, Shift Right - Get It Right
The DevOps Dance - Shift Left, Shift Right - Get It RightThe DevOps Dance - Shift Left, Shift Right - Get It Right
The DevOps Dance - Shift Left, Shift Right - Get It Right
Inflectra
 
Agile testing alliance cp aat highlights 1.2
Agile testing alliance cp aat highlights 1.2Agile testing alliance cp aat highlights 1.2
Agile testing alliance cp aat highlights 1.2
Agile Testing Alliance
 
Understanding Agile 11x17
Understanding Agile 11x17Understanding Agile 11x17
Understanding Agile 11x17
Nigel Thurlow
 
Scrum gathering Paris 2013 - test automation strategy for Scrum Projects
Scrum gathering Paris 2013 -  test automation strategy for Scrum ProjectsScrum gathering Paris 2013 -  test automation strategy for Scrum Projects
Scrum gathering Paris 2013 - test automation strategy for Scrum Projects
Eliane Collins
 
Selenium certification program
Selenium certification programSelenium certification program
Selenium certification program
shivramm
 
Agile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated TestingAgile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated Testing
Dimitri Ponomareff
 
Agile testing - Testing From Day 1
Agile testing - Testing From Day 1Agile testing - Testing From Day 1
Agile testing - Testing From Day 1
Kaizenko
 
Selenium Certification
Selenium CertificationSelenium Certification
Selenium Certification
Vskills
 
CP-SAT - Certified Professional Selenium Automation Testing
CP-SAT - Certified Professional Selenium Automation TestingCP-SAT - Certified Professional Selenium Automation Testing
CP-SAT - Certified Professional Selenium Automation Testing
Agile Testing Alliance
 
Testing automation in agile environment
Testing automation in agile environmentTesting automation in agile environment
Testing automation in agile environment
Perfecto Mobile
 
Introduction to Test Automation - Technology and Tools
Introduction to Test Automation - Technology and ToolsIntroduction to Test Automation - Technology and Tools
Introduction to Test Automation - Technology and Tools
KMS Technology
 
Rakuten presentation qa_night
Rakuten presentation qa_nightRakuten presentation qa_night
Rakuten presentation qa_night
Yusuke Nakamura
 
7 Deadly Sins of Agile Software Test Automation
7 Deadly Sins of Agile Software Test Automation7 Deadly Sins of Agile Software Test Automation
7 Deadly Sins of Agile Software Test Automation
Adrian Smith
 
Large-Scale Agile Test Automation Strategies in Practice
Large-Scale Agile Test Automation Strategies in PracticeLarge-Scale Agile Test Automation Strategies in Practice
Large-Scale Agile Test Automation Strategies in Practice
TechWell
 
Test automation - What? Why? How?
Test automation - What? Why? How?Test automation - What? Why? How?
Test automation - What? Why? How?
Anand Bagmar
 
Agile tour ncr test360_degree - agile testing on steroids
Agile tour ncr test360_degree - agile testing on steroidsAgile tour ncr test360_degree - agile testing on steroids
Agile tour ncr test360_degree - agile testing on steroids
Vipul Gupta
 
Agile Testing - presentation for Agile User Group
Agile Testing - presentation for Agile User GroupAgile Testing - presentation for Agile User Group
Agile Testing - presentation for Agile User Group
suwalki24.pl
 
The DevOps Dance - Shift Left, Shift Right - Get It Right
The DevOps Dance - Shift Left, Shift Right - Get It RightThe DevOps Dance - Shift Left, Shift Right - Get It Right
The DevOps Dance - Shift Left, Shift Right - Get It Right
Inflectra
 
Agile testing alliance cp aat highlights 1.2
Agile testing alliance cp aat highlights 1.2Agile testing alliance cp aat highlights 1.2
Agile testing alliance cp aat highlights 1.2
Agile Testing Alliance
 
Understanding Agile 11x17
Understanding Agile 11x17Understanding Agile 11x17
Understanding Agile 11x17
Nigel Thurlow
 
Scrum gathering Paris 2013 - test automation strategy for Scrum Projects
Scrum gathering Paris 2013 -  test automation strategy for Scrum ProjectsScrum gathering Paris 2013 -  test automation strategy for Scrum Projects
Scrum gathering Paris 2013 - test automation strategy for Scrum Projects
Eliane Collins
 
Selenium certification program
Selenium certification programSelenium certification program
Selenium certification program
shivramm
 

Similar to Introduction of unit test to management (20)

Automation Concepts
Automation ConceptsAutomation Concepts
Automation Concepts
Nishant Worah
 
Software presentation
Software presentationSoftware presentation
Software presentation
JennaPrengle
 
Automated Testing with Agile
Automated Testing with AgileAutomated Testing with Agile
Automated Testing with Agile
Ken McCorkell
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
Gian Maria Ricci
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
ZendCon
 
Unit testing
Unit testing Unit testing
Unit testing
dubbu
 
Software Testing - A sneak preview By Srikanth
Software Testing - A sneak preview By SrikanthSoftware Testing - A sneak preview By Srikanth
Software Testing - A sneak preview By Srikanth
Srikanth Krishnamoorthy
 
Role Of Qa And Testing In Agile 1225221397167302 8
Role Of Qa And Testing In Agile 1225221397167302 8Role Of Qa And Testing In Agile 1225221397167302 8
Role Of Qa And Testing In Agile 1225221397167302 8
a34sharm
 
Futureofqa
FutureofqaFutureofqa
Futureofqa
amitagarwal2006
 
Future of QA
Future of QAFuture of QA
Future of QA
amitagarwal2006
 
Software testing
Software testingSoftware testing
Software testing
YashasviSingh23
 
Software testing
Software testingSoftware testing
Software testing
Brajesh Pandey
 
Software testing
Software testingSoftware testing
Software testing
Rakshitha Raviprakash
 
Software test proposal
Software test proposalSoftware test proposal
Software test proposal
ManikandanRamanujam
 
Demo1ghjkl
Demo1ghjklDemo1ghjkl
Demo1ghjkl
crazyvirtue
 
Software testing
Software testingSoftware testing
Software testing
suneeth kumar
 
Software testing2
Software testing2Software testing2
Software testing2
suneeth kumar
 
Software testing
Software testingSoftware testing
Software testing
Rtr Sasi Tharan
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
priya_trivedi
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
priya_trivedi
 
Ad

Recently uploaded (20)

Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Ad

Introduction of unit test to management

  • 1. Introduction of Unit Test to Management and Business August, 2012 Wei Li
  • 2. ”To err is human; to forgive, divine.” Alexander Pope
  • 3.  Developer Test – Unit Test – Integration Test – Regression Test  QA Test – Integration Test – Regression Test – Performance Test – Stress Test  Customer/User Test – Acceptability Test – Usability Test Many Tests in the Life Cycle of Software Development
  • 4. What is Unit Test  Self checking or validation to ensure the code work as expected  Developer’s test  Part of construction cycle  Foundation of all other tests
  • 5. Where Does Unit Test Fit in Life Cycle?  Requirement gathering  Business Design  Technical Design – Architecture Design – Technical Design  Construction – Code and Unit Test  QA Test  Performance Test  User Test
  • 6. Unit Test Is Not  QA test  Customer/user test
  • 7. Why?  What? Write code to test code?  No! I don’t have time for it!
  • 8. Benefits of Unit Test – Instant Feedback  Unit test provides the earliest opportunity to identify and fix a defect  The earlier an error is found, the less expensive it is to fix it  Performed before components are integrated together
  • 9.  Force the developer to write clean and testable code – which leads to less complexity and better design  If your code is hard to be tested, how can it be easily used, maintained and extended? Benefits of Unit Test – Write Testable Code
  • 10. Benefits of Unit Test – Establish Safety Net in the Lifecycle  Can be used as part of regression test suite  Provide the green light to refactor old code and make changes
  • 11. Benefits of Unit Test – Good Way to Work with Legacy/Existing Code  Write unit test to get started understanding legacy code and system
  • 12. Benefits of Unit Test – Excellent Way to Learn New Language and API  Write unit test cases to learn and try new API  The unit test cases can become reusable knowledge base
  • 13. Benefits of Unit Test – Excellent Way to Report a Defect  Write a unit test case to report a defect or a bug in the system  Run the same test to verify the defect is fixed
  • 14. Benefits of Unit Test - Reusability  Write once run forever – reusable and repeatable  Save time long term in the life cycle  Give new team member a good jump start
  • 15. Unit Test Practice  Planning and estimation - account for the construction time for unit test  Code a little and unit test a little - repeat the cycle until the construction is done  Part of the code review process  Run unit test when trouble shooting issues  Run unit test whenever a change is made  Run unit test whenever is needed  Enjoy the results
  • 16.  Our old friend JUnit is still our best friend – No new wheel was reinvented – De facto tool – Familiarity to most developers Unit Test Practice
  • 17.  Use a separate unit test project – Only contain unit test related Java code but test code in other projects – Run locally and not deployed to application server  Won’t be part of the deployable to application server – Freedom to write more unit tests – Save time in testing (no build and deployment) Unit Test Practice
  • 18.  Unit test coverage – the thorough the better Unit Test Practice
  • 19.  Just do it and it will become a habit  You will find out you actually have time to write unit test code  You will find out you actually enjoy doing it Unit Test Practice
  • 20. Test Driven/Test First Methodology  Write a test case for a new functionality  Run the test and it fails  Write just enough code to make the test pass  Run the test and it passes  Refactor the code to make it better  Repeat the test  Repeat the cycle
  • 21. Continuous Integration  Get the latest version of the code from source control system  Build/compile the code  Run all unit test cases  Publish the build and test results  Notify the development team for any failure  Repeat the process periodically, for example, once every hour
  • 22. ”To err is developer; to catch early, unit test.”