testing from the trenches - salesforce1 world tour 2014
DESCRIPTION
As the Salesforce1 World Tour moves to London on May 22nd 2014, Force.com MVP's Chris Lewis and Simon Lawrence present the 15:00 Developer Stage Session on Testing Best Practices for the Salesforce.com Platform.TRANSCRIPT
![Page 1: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/1.jpg)
Testing From The TrenchesMay 22nd, 2014
![Page 2: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/2.jpg)
Christopher Alun Lewis
Advanced Developer
Force.com MVP
A Developers Perspective
Simon Lawrence
Certified Developer
Force.com MVP
http://www.slideshare.net/SimonLawrence4
![Page 3: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/3.jpg)
Why Do We Test?• Testing is required by Salesforce.com to release code to production
environments
• Regression Protection Against Future Changes
• Salesforce make 3 Platform Releases a Year
• Residing in a Multi-Tenancy Environment
• To Rid Your Systems of Bugs
![Page 4: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/4.jpg)
Testing on Salesforce
Our 5 Top Tips for Testing
![Page 5: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/5.jpg)
#1 Always Include Assertions
• These are what we call “Skeleton Tests”
• Other than avoiding exceptions, provide almost no use
• Missing a great opportunity to provide feedback on future
failure scenarios
![Page 6: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/6.jpg)
#1 Always Include AssertionsThe Code
![Page 7: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/7.jpg)
#1 Always Include AssertionsThe Criminal Test
![Page 8: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/8.jpg)
#1 Always Include AssertionsThe Correct Test
![Page 9: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/9.jpg)
#2 Remember your Batch Scenarios
• Your code may need to process large collections objects,
ensure that your tests cover this
• A serious consideration for testing your system’s ability to
operate within the governor limits
![Page 10: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/10.jpg)
#2 Remember your Batch ScenariosThe Code
![Page 11: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/11.jpg)
#2 Remember your Batch ScenariosThe Criminal Test
![Page 12: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/12.jpg)
#2 Remember your Batch ScenariosThe Correct Test
![Page 13: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/13.jpg)
#3 Test Roles with RunAs
• Test execution defaults to running as System Admin
• Using RunAs allows you to test your sharing rules and
record access rights
![Page 14: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/14.jpg)
#3 Test Roles with RunAs
![Page 15: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/15.jpg)
#3 Test Roles with RunAsThe Correct Test
![Page 16: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/16.jpg)
#4 Test Every Branch of Logic
• Making sure test cases traverse every possible logical
route through your code
• Crucial pieces of logic can be hidden in IF/ELSE blocks
![Page 17: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/17.jpg)
#4 Test Every Branch of LogicThe Code
![Page 18: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/18.jpg)
#4 Test Every Branch of LogicThe Criminal Test
![Page 19: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/19.jpg)
#4 Test Every Branch of LogicThe Coverage
![Page 20: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/20.jpg)
#4 Test Every Branch of LogicThe Correct Test
![Page 21: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/21.jpg)
#5 The 75% Squad
• Those developers who just strive to get to the 75% mark
• Normally guilty of most of the other crimes
• There’s no future for their code and their work
![Page 22: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/22.jpg)
#5 The 75% SquadThe Code
![Page 23: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/23.jpg)
#5 The 75% SquadThe Criminal Test
![Page 24: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/24.jpg)
#5 The 75% SquadThe Coverage
![Page 25: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/25.jpg)
The Wrap Up
• Always have test Assertions
• Batch test your Triggers
• RunAs different Users in your tests
• Cover every branch of your logical flow
• Don’t just aim for 75%
![Page 26: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/26.jpg)
Resources
• These Slides
http://www.slideshare.net/SimonLawrence4
• Developer Resources
https://developer.salesforce.com
https://developer.salesforce.com/page/How_to_Write_Good_Unit_Tests
• Salesforce Stack Exchange
http://salesforce.stackexchange.com/
![Page 27: Testing From The Trenches - Salesforce1 World Tour 2014](https://reader034.vdocuments.mx/reader034/viewer/2022051208/5466b4acaf795917078b6240/html5/thumbnails/27.jpg)
Thank You!
Christopher Alun
Lewis
@ChrisAlunLewis
Simon Lawrence
@srlawr