unit testing: not just for apex
TRANSCRIPT
![Page 1: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/1.jpg)
Unit Testing More than Apex Testing the Declarative Side of the Salesforce1 Platform
Mike Chale Senior Developer @Trifecta @mike_chale
![Page 2: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/2.jpg)
Deliver consistent customer experiences across web, mobile, and eCommerce platforms that are fully integrated into your business systems.
20+ Years developing enterprise solutions, primarily focused on commerce
100+ Salesforce Certifications, including a Salesforce MVP
Trifecta Commerce – Available on the AppExchange
Native app, streamlines order entry supporting B2B and B2B2C commerce.
Top Industries Served:
Manufacturing/Distribution
CPG/Retail
Life Sciences
Hospitality and Entertainment
Who is Trifecta?
Visit our booth – #2021 Moscone North
![Page 3: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/3.jpg)
Unit testing has one job . . .
Source: https://www.pinterest.com/pin/460141286900183385/
![Page 4: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/4.jpg)
1. Ensure customizations work as expected
2. Verify edge cases
3. Make changes confidently
4. Preserve knowledge
Why Unit Test?
![Page 5: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/5.jpg)
When I saw the light. . .
. . . this was step 1 of a 3 step field update process
![Page 6: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/6.jpg)
1. Change Management
2. Declarative features replacing code
3. Save time
Why Unit Test Metadata?
![Page 7: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/7.jpg)
1. Verify sObject rules
1. Required fields
2. Lookup filters
3. Validation rules
Unit Testing Metadata
![Page 8: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/8.jpg)
§ Leads are converted without contact information!
§ Need company size on Lead for classification
§ Accounts have their Key Contact outside of the company
Sample Request #1
![Page 9: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/9.jpg)
Demo
![Page 10: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/10.jpg)
1. Verify sObject rules
2. Verify critical processes
Unit Testing Metadata
![Page 11: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/11.jpg)
1. Are the entry criteria working as expected?
2. Is it going to the correct person/people?
3. Check all branches
Verifying Approval Processes
![Page 12: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/12.jpg)
§ All “big deals” need to be approved
§ Deals worth at least $50,000 go to manager
§ Deals over $100,000 require secondary approval
Sample Request #2
![Page 13: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/13.jpg)
Demo
![Page 14: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/14.jpg)
1. Verify sObject rules
2. Verify critical processes
3. Verify complex Process Builder
1. Post to Chatter
2. Auto-submit Approval
Unit Testing Metadata
![Page 15: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/15.jpg)
§ Processes can have multiple branches
§ Each branch can perform multiple steps
§ Post to Chatter
§ Update self / related records
§ Submit for Approval
§ Invoke Apex and Flows
Testing Process Builder
![Page 16: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/16.jpg)
§ Approval Process is great!
§ Can the Opportunity be submitted automatically?
§ And @mention the manager
Sample Request #3
![Page 17: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/17.jpg)
Demo
![Page 18: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/18.jpg)
1. Verify sObject rules
2. Verify critical processes
3. Verify complex Process Builder
1. Post to Chatter
2. Auto-submit Approval
3. Update and create records
Unit Testing Metadata
![Page 19: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/19.jpg)
§ Need reminders!
§ Can we automatically convert an Opportunity to an Order?
§ And create the Contract?
Sample Request #4
![Page 20: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/20.jpg)
Demo
![Page 21: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/21.jpg)
§ Complex orgs have many interactions
§ Workflows and Process Builder can be complex
§ Save time with regression testing
Recap
![Page 22: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/22.jpg)
§ Presentation and sample code - https://github.com/chalemic/UnitTestingMoreThanApex
§ How to Write Good Unit Tests - https://developer.salesforce.com/page/How_to_Write_Good_Unit_Tests
§ Testing Best Practices - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_best_practices.htm
§ Apex Approval Processing Example - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_example.htm
§ Apex Lead Convert Class - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_convertLead.htm
Resources
![Page 23: Unit Testing: Not Just for Apex](https://reader031.vdocuments.mx/reader031/viewer/2022020214/58a455a01a28ab55068b5efd/html5/thumbnails/23.jpg)
Thank you