From the course: Introduction to Test Classes in Salesforce
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Testing @future - Salesforce Tutorial
From the course: Introduction to Test Classes in Salesforce
Testing @future
- [Instructor] One of the areas in Salesforce that we need to test is our @Future code. This could also be applied to our @Queuable code. So we're going to look at @Future, look at how it's used in Salesforce, and then we're going to look at how do we actually test it. Let me flip over to the code at this point. In this particular case we have an Opportunity trigger, and our trigger follows the standard recommend method of handling all of the various after delete, before insert, after insert, etc. And then calling out to our trigger handler to actually process these triggers as they come in. If we look at our trigger handler, one of the things we've done on the OnBeforeUpdate is we're actually looking to see if the test code is running. Now the reason we would be interested in doing this is in actual production instance we probably have a lot of records we're processing, we may be in an extremely long thread that's executing. For example, in the current organization that I work in…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.