SlideShare uma empresa Scribd logo
1 de 16
© 2013 IBM Corporation
Paul Thwaite IBM, Stuart Marks Oracle.
BOF 4255
Ten Things You Should Know
When Writing Good Unit Test
Cases in Java
Document number
© 2013 IBM Corporation
Important Disclaimers
THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY.
WHILST EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION
CONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED.
ALL PERFORMANCE DATA INCLUDED IN THIS PRESENTATION HAVE BEEN GATHERED IN A CONTROLLED
ENVIRONMENT. YOUR OWN TEST RESULTS MAY VARY BASED ON HARDWARE, SOFTWARE OR
INFRASTRUCTURE DIFFERENCES.
ALL DATA INCLUDED IN THIS PRESENTATION ARE MEANT TO BE USED ONLY AS A GUIDE.
IN ADDITION, THE INFORMATION CONTAINED IN THIS PRESENTATION IS BASED ON IBM’S CURRENT PRODUCT
PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM, WITHOUT NOTICE.
IBM AND ITS AFFILIATED COMPANIES SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE
USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION.
NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF:
- CREATING ANY WARRANT OR REPRESENTATION FROM IBM, ITS AFFILIATED COMPANIES OR ITS OR THEIR
SUPPLIERS AND/OR LICENSORS
2
© 2013 IBM Corporation
Who are we?
 Paul Thwaite
– QA Engineer, IBM
 Stuart Marks
– Principal Member of Technical Staff, Oracle
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
What are you testing?
Why are you testing?
Plan
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
Comments
Expected behaviour
Aid debug
Diagnostics
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
Separate test logic / setup
Much easier to debug
Use setup / teardown
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
One scenario per test
Enables fast debug
Obvious why test failed
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
Run unit tests often as possible
Maintain quality bar
Quick results
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
Non-deterministic tests
are a headache
Fix intermittent tests immediately
No value, waste of resource
Must trust all tests
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
Must run in any order
Run subset, faster results
No dependencies
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
Use message in asserts
Make it simple to debug
Reference input data
Record test environment info
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
No ports, IP addresses,
data files, databases
Use config files, system
properties or mock objects
Portable tests
© 2013 IBM Corporation
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and simple”
4. Test one thing only
5. Fast tests only
6. Absolute repeatability
7. Independent tests only
8. Provide diagnostic data on failure
9. No hard-coding of your
environment
A passing test is a silent test
Too much output = confusion
Use option, config file to
turn on debug, save output
© 2013 IBM Corporation
Over to you
 What are your experiences with unit testing ideals vs. real world?
 What testing problems and pathologies have you encountered?
 What are the root causes of your testing problems?
 What is the cost of test maintenance?
© 2013 IBM Corporation16
Visit IBM booth #5112
 Visit the IBM booth 5112 for QA queries
–09:30 – 12:00
–Tuesday 24 September
 Meet other IBM developers at JavaOne
 Checkout what IBM is doing at JavaOne
Tue 24 Sept, 09:30-12:00http://ibm.co/JavaOne

Mais conteúdo relacionado

Mais procurados

Ebs performance tuning session feb 13 2013---Presented by Oracle
Ebs performance tuning session  feb 13 2013---Presented by OracleEbs performance tuning session  feb 13 2013---Presented by Oracle
Ebs performance tuning session feb 13 2013---Presented by OracleAkash Pramanik
 
Windows 7 For Geeks
Windows 7 For GeeksWindows 7 For Geeks
Windows 7 For GeeksAdil Mughal
 
DUG'20: 01 - Welcome & DAOS Update
DUG'20: 01 - Welcome & DAOS UpdateDUG'20: 01 - Welcome & DAOS Update
DUG'20: 01 - Welcome & DAOS UpdateAndrey Kudryavtsev
 
Dell-EMC Remote Acess Controller "DRAC" 10 Features For "Power" Users
Dell-EMC Remote Acess Controller "DRAC" 10 Features For "Power" UsersDell-EMC Remote Acess Controller "DRAC" 10 Features For "Power" Users
Dell-EMC Remote Acess Controller "DRAC" 10 Features For "Power" UsersMark Maclean
 
Oracle licensing on VMware, Cloud, Hyper V and other virtualised platforms
Oracle licensing on VMware, Cloud, Hyper V and other virtualised platformsOracle licensing on VMware, Cloud, Hyper V and other virtualised platforms
Oracle licensing on VMware, Cloud, Hyper V and other virtualised platformsOnomi
 
Cloud Technology: Now Entering the Business Process Phase
Cloud Technology: Now Entering the Business Process PhaseCloud Technology: Now Entering the Business Process Phase
Cloud Technology: Now Entering the Business Process Phasefinteligent
 
Virtualization aware Java VM
Virtualization aware Java VMVirtualization aware Java VM
Virtualization aware Java VMTim Ellison
 
Best Practices with IPS on Oracle Solaris 11
Best Practices with IPS on Oracle Solaris 11Best Practices with IPS on Oracle Solaris 11
Best Practices with IPS on Oracle Solaris 11glynnfoster
 
UKOUG APPS 14: Optimizing Performance for Oracle EPM Systems
UKOUG APPS 14: Optimizing Performance for Oracle EPM SystemsUKOUG APPS 14: Optimizing Performance for Oracle EPM Systems
UKOUG APPS 14: Optimizing Performance for Oracle EPM SystemsAlithya
 
Om enterprise labs session leader
Om enterprise labs session leaderOm enterprise labs session leader
Om enterprise labs session leaderMark Maclean
 
Optimizing Oracle licensing in VMware environments
Optimizing Oracle licensing in VMware environments Optimizing Oracle licensing in VMware environments
Optimizing Oracle licensing in VMware environments iQuate
 
Understanding oracle certification_support_licensing_v_mware_environments
Understanding oracle certification_support_licensing_v_mware_environmentsUnderstanding oracle certification_support_licensing_v_mware_environments
Understanding oracle certification_support_licensing_v_mware_environmentsMarina Farioli
 
Oracle Solaris 11 - Best for Enterprise Applications
Oracle Solaris 11 - Best for Enterprise ApplicationsOracle Solaris 11 - Best for Enterprise Applications
Oracle Solaris 11 - Best for Enterprise Applicationsglynnfoster
 
IAITAM Webinar: How to Optimize Oracle licensing in VMware environments
IAITAM Webinar: How to Optimize Oracle licensing in VMware environments IAITAM Webinar: How to Optimize Oracle licensing in VMware environments
IAITAM Webinar: How to Optimize Oracle licensing in VMware environments iQuate
 
Dhct config report
Dhct config reportDhct config report
Dhct config reportSan Man
 
EDB Postgres Failover Manager
EDB Postgres Failover ManagerEDB Postgres Failover Manager
EDB Postgres Failover ManagerEDB
 
Oracle Database Licensing Rules
Oracle Database Licensing RulesOracle Database Licensing Rules
Oracle Database Licensing RulesDoddi Priyambodo
 

Mais procurados (20)

Em13c New Features- Two of Two
Em13c New Features- Two of TwoEm13c New Features- Two of Two
Em13c New Features- Two of Two
 
Em13c features- HotSos 2016
Em13c features- HotSos 2016Em13c features- HotSos 2016
Em13c features- HotSos 2016
 
Ebs performance tuning session feb 13 2013---Presented by Oracle
Ebs performance tuning session  feb 13 2013---Presented by OracleEbs performance tuning session  feb 13 2013---Presented by Oracle
Ebs performance tuning session feb 13 2013---Presented by Oracle
 
Windows 7 For Geeks
Windows 7 For GeeksWindows 7 For Geeks
Windows 7 For Geeks
 
DUG'20: 01 - Welcome & DAOS Update
DUG'20: 01 - Welcome & DAOS UpdateDUG'20: 01 - Welcome & DAOS Update
DUG'20: 01 - Welcome & DAOS Update
 
Dell-EMC Remote Acess Controller "DRAC" 10 Features For "Power" Users
Dell-EMC Remote Acess Controller "DRAC" 10 Features For "Power" UsersDell-EMC Remote Acess Controller "DRAC" 10 Features For "Power" Users
Dell-EMC Remote Acess Controller "DRAC" 10 Features For "Power" Users
 
Oracle licensing on VMware, Cloud, Hyper V and other virtualised platforms
Oracle licensing on VMware, Cloud, Hyper V and other virtualised platformsOracle licensing on VMware, Cloud, Hyper V and other virtualised platforms
Oracle licensing on VMware, Cloud, Hyper V and other virtualised platforms
 
Cloud Technology: Now Entering the Business Process Phase
Cloud Technology: Now Entering the Business Process PhaseCloud Technology: Now Entering the Business Process Phase
Cloud Technology: Now Entering the Business Process Phase
 
Virtualization aware Java VM
Virtualization aware Java VMVirtualization aware Java VM
Virtualization aware Java VM
 
Best Practices with IPS on Oracle Solaris 11
Best Practices with IPS on Oracle Solaris 11Best Practices with IPS on Oracle Solaris 11
Best Practices with IPS on Oracle Solaris 11
 
UKOUG APPS 14: Optimizing Performance for Oracle EPM Systems
UKOUG APPS 14: Optimizing Performance for Oracle EPM SystemsUKOUG APPS 14: Optimizing Performance for Oracle EPM Systems
UKOUG APPS 14: Optimizing Performance for Oracle EPM Systems
 
Om enterprise labs session leader
Om enterprise labs session leaderOm enterprise labs session leader
Om enterprise labs session leader
 
Optimizing Oracle licensing in VMware environments
Optimizing Oracle licensing in VMware environments Optimizing Oracle licensing in VMware environments
Optimizing Oracle licensing in VMware environments
 
The application model in real life
The application model in real lifeThe application model in real life
The application model in real life
 
Understanding oracle certification_support_licensing_v_mware_environments
Understanding oracle certification_support_licensing_v_mware_environmentsUnderstanding oracle certification_support_licensing_v_mware_environments
Understanding oracle certification_support_licensing_v_mware_environments
 
Oracle Solaris 11 - Best for Enterprise Applications
Oracle Solaris 11 - Best for Enterprise ApplicationsOracle Solaris 11 - Best for Enterprise Applications
Oracle Solaris 11 - Best for Enterprise Applications
 
IAITAM Webinar: How to Optimize Oracle licensing in VMware environments
IAITAM Webinar: How to Optimize Oracle licensing in VMware environments IAITAM Webinar: How to Optimize Oracle licensing in VMware environments
IAITAM Webinar: How to Optimize Oracle licensing in VMware environments
 
Dhct config report
Dhct config reportDhct config report
Dhct config report
 
EDB Postgres Failover Manager
EDB Postgres Failover ManagerEDB Postgres Failover Manager
EDB Postgres Failover Manager
 
Oracle Database Licensing Rules
Oracle Database Licensing RulesOracle Database Licensing Rules
Oracle Database Licensing Rules
 

Semelhante a Ten things you should know when writing good unit test cases

Fantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test DesignFantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test DesignWinston Laoh
 
End-to-End Automated Testing: Lessons from Zombieland
End-to-End Automated Testing: Lessons from ZombielandEnd-to-End Automated Testing: Lessons from Zombieland
End-to-End Automated Testing: Lessons from ZombielandJosiah Renaudin
 
Lessons Learned in Test Automation From Zombieland
Lessons Learned in Test Automation From ZombielandLessons Learned in Test Automation From Zombieland
Lessons Learned in Test Automation From ZombielandMatt Barbour
 
Chaos Engineering - Limiting Damage During Chaos Experiments
Chaos Engineering - Limiting Damage During Chaos ExperimentsChaos Engineering - Limiting Damage During Chaos Experiments
Chaos Engineering - Limiting Damage During Chaos ExperimentsNils Meder
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Developmentsatya sudheer
 
Solving Flaky Automated Tests Using Machine Learning
Solving Flaky Automated Tests Using Machine LearningSolving Flaky Automated Tests Using Machine Learning
Solving Flaky Automated Tests Using Machine LearningJames Farrier
 
The Developer’s Guide to Test Automation
The Developer’s Guide to Test AutomationThe Developer’s Guide to Test Automation
The Developer’s Guide to Test AutomationTechWell
 
Curiosity software Ireland and Perfecto present: achieving in-sprint regressi...
Curiosity software Ireland and Perfecto present: achieving in-sprint regressi...Curiosity software Ireland and Perfecto present: achieving in-sprint regressi...
Curiosity software Ireland and Perfecto present: achieving in-sprint regressi...Curiosity Software Ireland
 
The Survey Says: Testers Spend Their Time Doing...
The Survey Says: Testers Spend Their Time Doing...The Survey Says: Testers Spend Their Time Doing...
The Survey Says: Testers Spend Their Time Doing...TechWell
 
DevOps in Practice: When does "Practice" Become "Doing"?
DevOps in Practice: When does "Practice" Become "Doing"?DevOps in Practice: When does "Practice" Become "Doing"?
DevOps in Practice: When does "Practice" Become "Doing"?Michael Elder
 
6 Easy Steps to Write Test Cases
6 Easy Steps to Write Test Cases6 Easy Steps to Write Test Cases
6 Easy Steps to Write Test CasesMichael Deady
 
Clean & Dirty Acceptance Tests with Cucumber & Watir
Clean & Dirty Acceptance Tests with Cucumber & WatirClean & Dirty Acceptance Tests with Cucumber & Watir
Clean & Dirty Acceptance Tests with Cucumber & WatirDanny Smith
 
Applying principles of chaos engineering to serverless (O'Reilly Software Arc...
Applying principles of chaos engineering to serverless (O'Reilly Software Arc...Applying principles of chaos engineering to serverless (O'Reilly Software Arc...
Applying principles of chaos engineering to serverless (O'Reilly Software Arc...Yan Cui
 
Exploring Best Practises in Design of Experiments: A Data Driven Approach to ...
Exploring Best Practises in Design of Experiments: A Data Driven Approach to ...Exploring Best Practises in Design of Experiments: A Data Driven Approach to ...
Exploring Best Practises in Design of Experiments: A Data Driven Approach to ...JMP software from SAS
 
You have no idea what your users want - WordCamp PDX
You have no idea what your users want - WordCamp PDXYou have no idea what your users want - WordCamp PDX
You have no idea what your users want - WordCamp PDXEvan Solomon
 
Nevera Dul Moment
Nevera Dul MomentNevera Dul Moment
Nevera Dul Momentkurtvm
 
Oracle Forms Performance Testing PushToTest TestMaker JAT
Oracle Forms Performance Testing PushToTest TestMaker JATOracle Forms Performance Testing PushToTest TestMaker JAT
Oracle Forms Performance Testing PushToTest TestMaker JATClever Moe
 
Load and Performance Testing in Production, featuring Scott Barber
Load and Performance Testing in Production, featuring Scott BarberLoad and Performance Testing in Production, featuring Scott Barber
Load and Performance Testing in Production, featuring Scott BarberNeotys
 

Semelhante a Ten things you should know when writing good unit test cases (20)

Fantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test DesignFantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test Design
 
End-to-End Automated Testing: Lessons from Zombieland
End-to-End Automated Testing: Lessons from ZombielandEnd-to-End Automated Testing: Lessons from Zombieland
End-to-End Automated Testing: Lessons from Zombieland
 
Lessons Learned in Test Automation From Zombieland
Lessons Learned in Test Automation From ZombielandLessons Learned in Test Automation From Zombieland
Lessons Learned in Test Automation From Zombieland
 
Chaos Engineering - Limiting Damage During Chaos Experiments
Chaos Engineering - Limiting Damage During Chaos ExperimentsChaos Engineering - Limiting Damage During Chaos Experiments
Chaos Engineering - Limiting Damage During Chaos Experiments
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Development
 
Solving Flaky Automated Tests Using Machine Learning
Solving Flaky Automated Tests Using Machine LearningSolving Flaky Automated Tests Using Machine Learning
Solving Flaky Automated Tests Using Machine Learning
 
The Developer’s Guide to Test Automation
The Developer’s Guide to Test AutomationThe Developer’s Guide to Test Automation
The Developer’s Guide to Test Automation
 
Curiosity software Ireland and Perfecto present: achieving in-sprint regressi...
Curiosity software Ireland and Perfecto present: achieving in-sprint regressi...Curiosity software Ireland and Perfecto present: achieving in-sprint regressi...
Curiosity software Ireland and Perfecto present: achieving in-sprint regressi...
 
The Survey Says: Testers Spend Their Time Doing...
The Survey Says: Testers Spend Their Time Doing...The Survey Says: Testers Spend Their Time Doing...
The Survey Says: Testers Spend Their Time Doing...
 
Dba tips and_tricks
Dba tips and_tricksDba tips and_tricks
Dba tips and_tricks
 
DevOps in Practice: When does "Practice" Become "Doing"?
DevOps in Practice: When does "Practice" Become "Doing"?DevOps in Practice: When does "Practice" Become "Doing"?
DevOps in Practice: When does "Practice" Become "Doing"?
 
6 Easy Steps to Write Test Cases
6 Easy Steps to Write Test Cases6 Easy Steps to Write Test Cases
6 Easy Steps to Write Test Cases
 
Insoft training day_1
Insoft training day_1Insoft training day_1
Insoft training day_1
 
Clean & Dirty Acceptance Tests with Cucumber & Watir
Clean & Dirty Acceptance Tests with Cucumber & WatirClean & Dirty Acceptance Tests with Cucumber & Watir
Clean & Dirty Acceptance Tests with Cucumber & Watir
 
Applying principles of chaos engineering to serverless (O'Reilly Software Arc...
Applying principles of chaos engineering to serverless (O'Reilly Software Arc...Applying principles of chaos engineering to serverless (O'Reilly Software Arc...
Applying principles of chaos engineering to serverless (O'Reilly Software Arc...
 
Exploring Best Practises in Design of Experiments: A Data Driven Approach to ...
Exploring Best Practises in Design of Experiments: A Data Driven Approach to ...Exploring Best Practises in Design of Experiments: A Data Driven Approach to ...
Exploring Best Practises in Design of Experiments: A Data Driven Approach to ...
 
You have no idea what your users want - WordCamp PDX
You have no idea what your users want - WordCamp PDXYou have no idea what your users want - WordCamp PDX
You have no idea what your users want - WordCamp PDX
 
Nevera Dul Moment
Nevera Dul MomentNevera Dul Moment
Nevera Dul Moment
 
Oracle Forms Performance Testing PushToTest TestMaker JAT
Oracle Forms Performance Testing PushToTest TestMaker JATOracle Forms Performance Testing PushToTest TestMaker JAT
Oracle Forms Performance Testing PushToTest TestMaker JAT
 
Load and Performance Testing in Production, featuring Scott Barber
Load and Performance Testing in Production, featuring Scott BarberLoad and Performance Testing in Production, featuring Scott Barber
Load and Performance Testing in Production, featuring Scott Barber
 

Último

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Último (20)

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Ten things you should know when writing good unit test cases

  • 1. © 2013 IBM Corporation Paul Thwaite IBM, Stuart Marks Oracle. BOF 4255 Ten Things You Should Know When Writing Good Unit Test Cases in Java Document number
  • 2. © 2013 IBM Corporation Important Disclaimers THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY. WHILST EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION CONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. ALL PERFORMANCE DATA INCLUDED IN THIS PRESENTATION HAVE BEEN GATHERED IN A CONTROLLED ENVIRONMENT. YOUR OWN TEST RESULTS MAY VARY BASED ON HARDWARE, SOFTWARE OR INFRASTRUCTURE DIFFERENCES. ALL DATA INCLUDED IN THIS PRESENTATION ARE MEANT TO BE USED ONLY AS A GUIDE. IN ADDITION, THE INFORMATION CONTAINED IN THIS PRESENTATION IS BASED ON IBM’S CURRENT PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM, WITHOUT NOTICE. IBM AND ITS AFFILIATED COMPANIES SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION. NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF: - CREATING ANY WARRANT OR REPRESENTATION FROM IBM, ITS AFFILIATED COMPANIES OR ITS OR THEIR SUPPLIERS AND/OR LICENSORS 2
  • 3. © 2013 IBM Corporation Who are we?  Paul Thwaite – QA Engineer, IBM  Stuart Marks – Principal Member of Technical Staff, Oracle
  • 4. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment
  • 5. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment What are you testing? Why are you testing? Plan
  • 6. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment Comments Expected behaviour Aid debug Diagnostics
  • 7. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment Separate test logic / setup Much easier to debug Use setup / teardown
  • 8. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment One scenario per test Enables fast debug Obvious why test failed
  • 9. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment Run unit tests often as possible Maintain quality bar Quick results
  • 10. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment Non-deterministic tests are a headache Fix intermittent tests immediately No value, waste of resource Must trust all tests
  • 11. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment Must run in any order Run subset, faster results No dependencies
  • 12. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment Use message in asserts Make it simple to debug Reference input data Record test environment info
  • 13. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment No ports, IP addresses, data files, databases Use config files, system properties or mock objects Portable tests
  • 14. © 2013 IBM Corporation 1. Think before you act 2. Make your tests understandable 3. Keep your tests “small and simple” 4. Test one thing only 5. Fast tests only 6. Absolute repeatability 7. Independent tests only 8. Provide diagnostic data on failure 9. No hard-coding of your environment A passing test is a silent test Too much output = confusion Use option, config file to turn on debug, save output
  • 15. © 2013 IBM Corporation Over to you  What are your experiences with unit testing ideals vs. real world?  What testing problems and pathologies have you encountered?  What are the root causes of your testing problems?  What is the cost of test maintenance?
  • 16. © 2013 IBM Corporation16 Visit IBM booth #5112  Visit the IBM booth 5112 for QA queries –09:30 – 12:00 –Tuesday 24 September  Meet other IBM developers at JavaOne  Checkout what IBM is doing at JavaOne Tue 24 Sept, 09:30-12:00http://ibm.co/JavaOne

Notas do Editor