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.

Getting the best value out of your unit tests


Published on

Unit Tests are vital to the success of your system, but they can be time consuming and sometimes they can feel like they just slow you down. So how do you limit the time you spend on them whilst maximising their value? By turning them into living, accurate and self proving documentation that your developers can rely on, that's how! We'll cover techniques that will both ensure you get the most out of the time spent on unit tests, and help you to spend less time on them too.

Supporting code samples here:

First Example:
* 1-0-ExampleHardToReadTest.cls
* 1-0-ExampleHardToReadTest-Annotated.cls

Second Example:
* 1-3-ExamplePreciselyExpressedTest.cls

Annotated interim versions also exist for review.

Published in: Software
  • Login to see the comments

  • Be the first to like this

Getting the best value out of your unit tests

  1. 1. Getting the best value out of your Unit Tests Unit Tests as Documentation - Expo Developer Theatre - 12:30pm Robert Baillie, Senior Technical Consultant - makepositive - @BobaliciousBob Salesforce World Tour, London, 23rd May
  2. 2. Getting the best value out of your Unit Tests Unit Tests as Documentation, @BobaliciousBob Robert Baillie, Senior Technical Consultant - makepositive
  3. 3. Rob Baillie Senior Technical Consultant @Bobalicious.Bob Speaker Logo
  4. 4. Getting the best value out of your Unit Tests Unit Tests as Documentation
  5. 5. What’s the context?
  6. 6. Give me some context... What’s Apex? • Domain Specific Language used to customise Salesforce. • Java-like, Object Oriented. • Abstractions for things like database access. What’s Unit Testing? • Required whenever we write Apex. • It’s Apex that tests other Apex. • Runs whenever we deploy changes to our Salesforce Orgs. • We have minimum requirements for the amount we do. Test s
  7. 7. Why is Unit Testing a good idea?
  8. 8. Prove the Functionality Ensure continuity / stop regression Document our Intent So, why do we Unit Test?
  9. 9. What are the benefits? Find bugs earlier in the process Stop accidental changes in behaviour Form a collective memory 100% accurate documentation Increase confidence to change
  10. 10. So how do we get there?
  11. 11. What do we need to do? Test for the right things Make sure our tests are / documentation is readable
  12. 12. Functionality Coverage Testing the right things Plan our tests up front Don’t just test the “Happy Path” Test for when things shouldn’t happen Think “What can go wrong when the users get hold of it?”
  13. 13. Tests as Documentation...
  14. 14. Let’s look at some code! Demo time
  15. 15. Express Meaning Use names to describe what things are for Do things in a logical order Take the reader on a journey
  16. 16. Remove unnecessary things Hide immaterial things Only set up the data you need Test one thing at a time Be Concise
  17. 17. Be Precise Be clear about what you’re testing Test for precise results
  18. 18. Let’s look at some better code! Demo time
  19. 19. Have standards for your tests Include Unit Tests in your code reviews Seek advice and learn Ok, Ok, but how do get there..?
  20. 20. GitHub Repository with examples: I have example code...
  21. 21. Trailblazer Community Groups 900+ Community Groups 1,500+ Community Group Leaders 250+ Meetings per month Meet peers, learn Salesforce together, build your network, and find mentors 80+ Countries Louise Lockie Salesforce MVP Women in Tech Leader
  22. 22. Connect with our Awesome London Groups 8 Groups to Explore - Salesforce Developers - Salesforce Admins - B2B Marketers - B2C Marketers - Government - Nonprofit - Women in Tech - Higher Education Regular Meetings Peer-peer learning Incredible networking
  23. 23. Trailblazer Community Conferences Eric Dreshfield Salesforce MVP 30+ 1-2 day conferences built by and for the community with thought leadership, peer-peer learning and awesome networking Big Sky Dreamin' CactusForce Florida Dreamin' ForceAcademyLA Forcelandia Midwest Dreamin' NorCal Dreamin' Northeast Dreamin' Phillyforce SkiForce Snowforce Southeast Dreamin' Texas Dreamin' True North Dreamin' WITness Success Punta Dreamin’ Czech Dreamin' dreamOle French Touch Dreamin' London's Calling North Africa Dreamin’ YeurDreamin' Japan Dreamin' Philippines Dreamin' DownUnder Dreaming Brisbane DownUnder Dreaming Melbourne DownUnder Dreaming Sydney 14 June 2019 16 Aug. 2019 20 Sept. 2019 18 Oct. 2019