Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
#JavaOne @spoole167 @stuartmarks
TEN SIMPLE RULES FOR WRITING
GREAT TESTCASES
#JavaOne @spoole167 @stuartmarks
Steve Poole : IBM
JVM Developer
DevOps practitioner
Developer Advocate
Stuart Marks : Ora...
#JavaOne @spoole167 @stuartmarks
“I get paid for code that works, not for tests”
How to maximize your effort
and protect y...
#JavaOne @spoole167 @stuartmarks
1. Think before you act
2. Make your tests understandable
3. Keep your tests “small and s...
#JavaOne @spoole167 @stuartmarks
1. Think before you act
What are
you testing?
Why are you
testing?
Plan
https://www.flick...
#JavaOne @spoole167 @stuartmarks
Unit
tests
Function
tests
System
tests
Developer QA
Easy to
understand
Long runningFast r...
#JavaOne @spoole167 @stuartmarks
2. Make your tests
understandable
Comments
Expected behaviour
Aid debug
Diagnostics
https...
#JavaOne @spoole167 @stuartmarks
3. Keep your tests
“small and simple”
Separate test logic / setup
Much easier to debug
Us...
#JavaOne @spoole167 @stuartmarks
4. Test one thing only
One scenario per test
Enables fast debug
Obvious why test failed
h...
#JavaOne @spoole167 @stuartmarks
5. Fast tests only
Run unit tests often as possible
Maintain quality bar
Quick results
ht...
#JavaOne @spoole167 @stuartmarks
6. Absolute repeatability
Non-deterministic
tests are a headache
Fix intermittent tests
i...
#JavaOne @spoole167 @stuartmarks
7. Independent tests only
Must run in any order
Run subset, faster results
No dependencie...
#JavaOne @spoole167 @stuartmarks
8. Provide diagnostic
data on failure
Use message in asserts
Make it simple to debug
Refe...
#JavaOne @spoole167 @stuartmarks
9. No hard-coding of
your environment
No ports, IP addresses,
data files, databases
Use c...
#JavaOne @spoole167 @stuartmarks
10. No extraneous output
A passing test is a silent test
Too much output = confusion
Use ...
#JavaOne @spoole167 @stuartmarks
Pirate rules
Guidelines only
Some may seen obvious.
Some may seem pedantic
Until you inhe...
Próxima SlideShare
Cargando en…5
×

Ten Simple Rules for Writing Great Test Cases (JavaOne 2017)

869 visualizaciones

Publicado el

We’ve all been there: debugging problems in a test and silently screaming into the dark. Poor test cases can cost you time and effort and degrade the quality of your application or product. Testing is vitally important, but so is having a test suite you can use effectively and can rely on. This session takes you through the top 10 rules for writing effective and reliable test cases. The new kids on the block such as Cloud and Docker and general “infrastructure as code”-style solutions may make you believe that old rules are just old. This presentation will make you think again. Knowledge gained from personal experience is always best. Learn from two old masters how to design great test cases, and maybe you’ll never have to visit the dark side again.

Publicado en: Tecnología
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

Ten Simple Rules for Writing Great Test Cases (JavaOne 2017)

  1. 1. #JavaOne @spoole167 @stuartmarks TEN SIMPLE RULES FOR WRITING GREAT TESTCASES
  2. 2. #JavaOne @spoole167 @stuartmarks Steve Poole : IBM JVM Developer DevOps practitioner Developer Advocate Stuart Marks : Oracle Principal MTS Java / OpenJDK Core Libraries
  3. 3. #JavaOne @spoole167 @stuartmarks “I get paid for code that works, not for tests” How to maximize your effort and protect your investment in tests and testing now with added Cloud
  4. 4. #JavaOne @spoole167 @stuartmarks 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 10.No extraneous output
  5. 5. #JavaOne @spoole167 @stuartmarks 1. Think before you act What are you testing? Why are you testing? Plan https://www.flickr.com/photos/ayurvedicmedicines/
  6. 6. #JavaOne @spoole167 @stuartmarks Unit tests Function tests System tests Developer QA Easy to understand Long runningFast running Complex Domain Knowledge required Dev QA Don’t think like this Think like this
  7. 7. #JavaOne @spoole167 @stuartmarks 2. Make your tests understandable Comments Expected behaviour Aid debug Diagnostics https://www.flickr.com/photos/83633410@N07/
  8. 8. #JavaOne @spoole167 @stuartmarks 3. Keep your tests “small and simple” Separate test logic / setup Much easier to debug Use setup / teardown https://www.flickr.com/photos/9266144@N02/
  9. 9. #JavaOne @spoole167 @stuartmarks 4. Test one thing only One scenario per test Enables fast debug Obvious why test failed https://www.flickr.com/photos/ryantron/
  10. 10. #JavaOne @spoole167 @stuartmarks 5. Fast tests only Run unit tests often as possible Maintain quality bar Quick results https://www.flickr.com/photos/mcleod/
  11. 11. #JavaOne @spoole167 @stuartmarks 6. Absolute repeatability Non-deterministic tests are a headache Fix intermittent tests immediately No value, waste of resource Must trust all tests https://www.flickr.com/photos/fdecomite/
  12. 12. #JavaOne @spoole167 @stuartmarks 7. Independent tests only Must run in any order Run subset, faster results No dependencies https://www.flickr.com/photos/sheila_sund/
  13. 13. #JavaOne @spoole167 @stuartmarks 8. Provide diagnostic data on failure Use message in asserts Make it simple to debug Reference input data Record test environment info https://www.flickr.com/photos/davidbaker/
  14. 14. #JavaOne @spoole167 @stuartmarks 9. No hard-coding of your environment No ports, IP addresses, data files, databases Use config files, system properties or mock objects Portable tests https://www.flickr.com/photos/pug50/
  15. 15. #JavaOne @spoole167 @stuartmarks 10. No extraneous output A passing test is a silent test Too much output = confusion Use option, config file to turn on debug, save output https://www.flickr.com/photos/3-bs/
  16. 16. #JavaOne @spoole167 @stuartmarks Pirate rules Guidelines only Some may seen obvious. Some may seem pedantic Until you inherit a testsuite… Thank you. https://www.flickr.com/photos/gapic/

×