From the course: Introduction to Test Classes in Salesforce

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Set up a test factory

Set up a test factory - Salesforce Tutorial

From the course: Introduction to Test Classes in Salesforce

Start my 1-month free trial

Set up a test factory

- [Instructor] Now that we've got our global constants in place, we've got our global utility setup. The next part of the test factory is we want to set up the pieces of the test factory that are going to remain pretty much the same regardless of the organization. So we're going to look at the methods here, createSObject, createSObject with a default ClassName, createSObjectlist, so on and so forth. These are methods that we're always going to have as part of our test class. One of the differences between the test factory and test utilities is that test factory is doing everything as an SObject. If you're not familiar with an SObject, every object in Salesforce, whether it's an account, whether it's opportunity, or it's a custom object that you've created, they all have a base SObject in them. So we're going to work at that base level. We're going to take these methods, and either retype them or copy and paste them into our org as our basics basis for our test factory. As you can see…

Contents