Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ten Simple Rules for Writing Great Testcases @ Devoxx US


Published on

We've all been there: debugging problems in a test case and silently screaming into the dark. (Sometimes not even silently.) Poor test case design can cost you significant time and effort let alone impact 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 will take you through the top ten rules for writing effective and reliable testcases.

The new kids on the block such as Cloud or Docker and general "Infrastructure as Code" style solutions may make you believe old rules are just old. This talk will make you think again. Knowledge gained from personal experience is always best. Learn from these old masters how to design great test cases and maybe you'll never have to visit the dark side again.

Published in: Technology
  • Hello! Get Your Professional Job-Winning Resume Here - Check our website!
    Are you sure you want to  Yes  No
    Your message goes here

Ten Simple Rules for Writing Great Testcases @ Devoxx US

  1. 1. #DevoxxUS @spoole167 @stuartmarks TEN SIMPLE RULES FOR WRITING GREAT TESTCASES
  2. 2. #DevoxxUS @spoole167 @stuartmarks Steve Poole : IBM JVM Developer DevOps practitioner Developer Advocate Stuart Marks : Oracle Principal MTS Java / OpenJDK Core Libraries
  3. 3. #DevoxxUS @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. #DevoxxUS @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. #DevoxxUS @spoole167 @stuartmarks 1. Think before you act What are you testing? Why are you testing? Plan
  6. 6. #DevoxxUS @spoole167 @stuartmarks 2. Make your tests understandable Comments Expected behaviour Aid debug Diagnostics
  7. 7. #DevoxxUS @spoole167 @stuartmarks 3. Keep your tests “small and simple” Separate test logic / setup Much easier to debug Use setup / teardown
  8. 8. #DevoxxUS @spoole167 @stuartmarks 4. Test one thing only One scenario per test Enables fast debug Obvious why test failed
  9. 9. #DevoxxUS @spoole167 @stuartmarks 5. Fast tests only Run unit tests often as possible Maintain quality bar Quick results
  10. 10. #DevoxxUS @spoole167 @stuartmarks 6. Absolute repeatability Non-deterministic tests are a headache Fix intermittent tests immediately No value, waste of resource Must trust all tests
  11. 11. #DevoxxUS @spoole167 @stuartmarks 7. Independent tests only Must run in any order Run subset, faster results No dependencies
  12. 12. #DevoxxUS @spoole167 @stuartmarks 8. Provide diagnostic data on failure Use message in asserts Make it simple to debug Reference input data Record test environment info
  13. 13. #DevoxxUS @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
  14. 14. #DevoxxUS @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
  15. 15. #DevoxxUS @spoole167 @stuartmarks Pirate rules Guidelines only Some may seen obvious. Some may seem pedantic Until you inherit a testsuite… Thank you.
  16. 16. © 2017 IBM Corporation Mission Badge #6: SMS Text Your mission should you choose to accept it…. Join us at the IBM Booth for hands-on labs, demos, games and talk to our developers. Text Mission2017 to 41411 to get the booth giveaway and learn more about all the IBM sessions & speakers. Enter the raffle by completing missions for a chance to win • a Drone • TJBot Kit • VR glasses