SlideShare a Scribd company logo
Unit Test Exp
Hieu T. Le
What is Unit Test?
What is a GOOD unit test?
• Automatic
• Thorough
• Repeatable
• Independent
• Professional
Unit Test Framework
• Provide a framework to
– Initialize/shutdown unit test environment
– Automated check fail/pass
• http://en.wikipedia.org/wiki/List_of_unit_test
ing_frameworks
– JUnit, CppUnit, CUnit, PhpUnit, NUnit, …
Unit Test Difficulties
• Test Case Generate
• Test Data Generate
• Environment
• Framework
• Effort vs. Schedule
• Thinking
• Process
Unit Test Environment
• Language: C, C++, Java
• Platform: Linux
• Framework: CppUnit, CUnit, JUnit, Google Test
• Tools: GCov, LCov, Jenkins
PROJECT A – PHASE 1
Language: C
Platform: vxWorks (Linux simulator)
Project A – Phase 1
• Difficulties
– Newbie team member
– Input return boolean, many alternatives path
– No hardware, use stub for many
vxWorks/hardware relating
– Schedule rush
Project A – Phase 1
• How can we work out?
– Experienced engineer build up unit test
framework for project
– Engineer does
• Basic test case: good case, bad case
• Additional test case for each code path
• Test data
• Verify result
Project A – Phase 1
• Lesson learnt
– It is bad when we focus too much into alternative
cases
– It is bad when we focus too much into unit test
coverage
– Unit test cannot be verified manually by eyes
PROJECT A – PHASE 2
Language: C
Platform: vxWorks (Linux simulator)
Project A – Phase 2
• Difficulties (from Phase 1)
– Unit test is verified manually
– Too many alternative cases
– Test data generating
Project A – Phase 2
• How can we work out?
– Experienced engineer refactor unit test framework
of phase 1
• Setup mechanism to ASSERT and automation
• Setup mechanism to automated generate test data
– Engineer does
• Run tool to generate test data for good/bad case
• Write additional test case for some alternatives code
path
Project A – Phase 2
• Lesson learnt
– Use tool to generate test data automatically
– Some engineer setup data without resetting it, it
makes other test case fail
– Should setup framework for mock object
– Should enforce fixing fail test case ASAP
PROJECT B
Language: Java, JNI, C++
Platform: Embedded Linux (cross run on PC)
Project B
• Difficulties
– Full stack application run on embedded board
which contains reference to many components
– Boot up time is long
– Cannot initialize all components for testing since it
depending on hardware
– Cannot run component standalone
– Cannot run on desktop PC
Project B
Project B
• How can we solve it?
– Experienced engineer setup a framework of unit
test using mock object approach
• Write mock object to wrap some components which
has many dependencies and depending on hardware
– Engineer does
• Write test case for the test component using developed
mock object
Project B
Mock Object
Project B
• Lesson learnt
– Use mock object so that we can control the result
– Use mock object to wrap some hardware
depending component
• Technologies used:
– Junit
– JMockit, Mockito
Thank You

More Related Content

PDF
Unit Testing from Setup to Deployment
PDF
Stacking Up Middleware
PDF
Writing Custom Puppet Types and Providers to Manage Web-Based Applications
PPTX
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
PDF
Puppet Systems Infrastructure Construction Kit
PDF
Puppet camp2021 testing modules and controlrepo
PDF
Javascript TDD with Jasmine, Karma, and Gulp
PPTX
Puppetizing Your Organization
Unit Testing from Setup to Deployment
Stacking Up Middleware
Writing Custom Puppet Types and Providers to Manage Web-Based Applications
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
Puppet Systems Infrastructure Construction Kit
Puppet camp2021 testing modules and controlrepo
Javascript TDD with Jasmine, Karma, and Gulp
Puppetizing Your Organization

What's hot (20)

PPTX
Vagrant+Rouster at salesforce.com
PPTX
Auto Deploy Deep Dive – vBrownBag Style
PDF
Test Driven Development With Python
ODP
Intro To Spring Python
PDF
Our Puppet Story (Linuxtag 2014)
PDF
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
PDF
Developing IT infrastructures with Puppet
PDF
Modules of the twenties
PDF
Puppet evolutions
PPTX
Applying software engineering to configuration management
PDF
Zend expressive workshop
PDF
Foundations of Zend Framework
ODT
Testing in-python-and-pytest-framework
PDF
Puppet Camp Paris 2016 Data in Modules
PDF
A Taste of Pharo 7.0
PDF
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
PDF
Command Line Arguments with Getopt::Long
PDF
Expressive Microservice Framework Blastoff
PDF
PuppetConf 2016: The Future of Testing Puppet Code – Gareth Rushgrove, Puppet
PDF
Tp install anything
Vagrant+Rouster at salesforce.com
Auto Deploy Deep Dive – vBrownBag Style
Test Driven Development With Python
Intro To Spring Python
Our Puppet Story (Linuxtag 2014)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Developing IT infrastructures with Puppet
Modules of the twenties
Puppet evolutions
Applying software engineering to configuration management
Zend expressive workshop
Foundations of Zend Framework
Testing in-python-and-pytest-framework
Puppet Camp Paris 2016 Data in Modules
A Taste of Pharo 7.0
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Command Line Arguments with Getopt::Long
Expressive Microservice Framework Blastoff
PuppetConf 2016: The Future of Testing Puppet Code – Gareth Rushgrove, Puppet
Tp install anything
Ad

Similar to Unit test (20)

PDF
Unit Testing Frameworks: A comparative study
PDF
Agile Testing Days
PDF
Software testing: an introduction - 2017
PPTX
2016 10-04: tdd++: tdd made easier
PPTX
8-testing.pptx
PDF
Introduction to test automation in java and php
PPS
Unit Testing
PDF
Unit testing - An introduction
PPS
Why unit testingl
PPS
Why Unit Testingl
PPS
Why Unit Testingl
PDF
Completely Test-Driven
PDF
Test-Driven Development (TDD)
PPTX
Skillwise Unit Testing
PPTX
The Test way
PDF
LDTT : A Low Level Driver Unit Testing Tool
PDF
Unit testing (eng)
PPTX
power point presentation of software testing amravati.pptx
PDF
P&MSP2012 - Unit Testing
PDF
Test driven development
Unit Testing Frameworks: A comparative study
Agile Testing Days
Software testing: an introduction - 2017
2016 10-04: tdd++: tdd made easier
8-testing.pptx
Introduction to test automation in java and php
Unit Testing
Unit testing - An introduction
Why unit testingl
Why Unit Testingl
Why Unit Testingl
Completely Test-Driven
Test-Driven Development (TDD)
Skillwise Unit Testing
The Test way
LDTT : A Low Level Driver Unit Testing Tool
Unit testing (eng)
power point presentation of software testing amravati.pptx
P&MSP2012 - Unit Testing
Test driven development
Ad

More from Hieu Le Trung (10)

PDF
[Hotshare.us]sat thu dau_mung_mu-thanhphong
ODT
Open source-options-v1
PPTX
Confluence vs. TWiki
PDF
Model For Applying Unit Test
PDF
Introduction To GCS' EMB Division
PPT
Microsoft Sync Framework
PDF
2 Effective Manufacturing Erp Mes
PPT
Global CyberSoft - MES Introduction
PPT
Virtualization & Global CyberSoft
PPT
Enterprise Project Management at Global CyberSoft
[Hotshare.us]sat thu dau_mung_mu-thanhphong
Open source-options-v1
Confluence vs. TWiki
Model For Applying Unit Test
Introduction To GCS' EMB Division
Microsoft Sync Framework
2 Effective Manufacturing Erp Mes
Global CyberSoft - MES Introduction
Virtualization & Global CyberSoft
Enterprise Project Management at Global CyberSoft

Recently uploaded (20)

PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
chapter 5 systemdesign2008.pptx for cimputer science students
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
assetexplorer- product-overview - presentation
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Website Design Services for Small Businesses.pdf
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PDF
Time Tracking Features That Teams and Organizations Actually Need
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
Custom Software Development Services.pptx.pptx
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
Tech Workshop Escape Room Tech Workshop
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
iTop VPN Crack Latest Version Full Key 2025
chapter 5 systemdesign2008.pptx for cimputer science students
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Why Generative AI is the Future of Content, Code & Creativity?
assetexplorer- product-overview - presentation
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Oracle Fusion HCM Cloud Demo for Beginners
Weekly report ppt - harsh dattuprasad patel.pptx
wealthsignaloriginal-com-DS-text-... (1).pdf
Website Design Services for Small Businesses.pdf
Autodesk AutoCAD Crack Free Download 2025
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
Time Tracking Features That Teams and Organizations Actually Need
Patient Appointment Booking in Odoo with online payment
Computer Software and OS of computer science of grade 11.pptx
Custom Software Development Services.pptx.pptx
Complete Guide to Website Development in Malaysia for SMEs
Tech Workshop Escape Room Tech Workshop
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)

Unit test

  • 2. What is Unit Test? What is a GOOD unit test? • Automatic • Thorough • Repeatable • Independent • Professional
  • 3. Unit Test Framework • Provide a framework to – Initialize/shutdown unit test environment – Automated check fail/pass • http://en.wikipedia.org/wiki/List_of_unit_test ing_frameworks – JUnit, CppUnit, CUnit, PhpUnit, NUnit, …
  • 4. Unit Test Difficulties • Test Case Generate • Test Data Generate • Environment • Framework • Effort vs. Schedule • Thinking • Process
  • 5. Unit Test Environment • Language: C, C++, Java • Platform: Linux • Framework: CppUnit, CUnit, JUnit, Google Test • Tools: GCov, LCov, Jenkins
  • 6. PROJECT A – PHASE 1 Language: C Platform: vxWorks (Linux simulator)
  • 7. Project A – Phase 1 • Difficulties – Newbie team member – Input return boolean, many alternatives path – No hardware, use stub for many vxWorks/hardware relating – Schedule rush
  • 8. Project A – Phase 1 • How can we work out? – Experienced engineer build up unit test framework for project – Engineer does • Basic test case: good case, bad case • Additional test case for each code path • Test data • Verify result
  • 9. Project A – Phase 1 • Lesson learnt – It is bad when we focus too much into alternative cases – It is bad when we focus too much into unit test coverage – Unit test cannot be verified manually by eyes
  • 10. PROJECT A – PHASE 2 Language: C Platform: vxWorks (Linux simulator)
  • 11. Project A – Phase 2 • Difficulties (from Phase 1) – Unit test is verified manually – Too many alternative cases – Test data generating
  • 12. Project A – Phase 2 • How can we work out? – Experienced engineer refactor unit test framework of phase 1 • Setup mechanism to ASSERT and automation • Setup mechanism to automated generate test data – Engineer does • Run tool to generate test data for good/bad case • Write additional test case for some alternatives code path
  • 13. Project A – Phase 2 • Lesson learnt – Use tool to generate test data automatically – Some engineer setup data without resetting it, it makes other test case fail – Should setup framework for mock object – Should enforce fixing fail test case ASAP
  • 14. PROJECT B Language: Java, JNI, C++ Platform: Embedded Linux (cross run on PC)
  • 15. Project B • Difficulties – Full stack application run on embedded board which contains reference to many components – Boot up time is long – Cannot initialize all components for testing since it depending on hardware – Cannot run component standalone – Cannot run on desktop PC
  • 17. Project B • How can we solve it? – Experienced engineer setup a framework of unit test using mock object approach • Write mock object to wrap some components which has many dependencies and depending on hardware – Engineer does • Write test case for the test component using developed mock object
  • 19. Project B • Lesson learnt – Use mock object so that we can control the result – Use mock object to wrap some hardware depending component • Technologies used: – Junit – JMockit, Mockito

Editor's Notes

  • #5: Process: follow up with failed test case immediately.