From the course: Introduction to Test Classes in Salesforce
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Customize a test factory - Salesforce Tutorial
From the course: Introduction to Test Classes in Salesforce
Customize a test factory
- [Instructor] Now that we've got our global constants set, we've set up our global utilities, we've set up all of the basic parts of the test factory. This is where we start customizing the test factory to match our organization. We're going to need to create a public class for each of the objects that we have in our system. For example, we've got an account, so we need AccountDefaults. We have a contact so we need a ContactDefaults. And what's unique here is the way in which this is mapped. So we're going to have the name of the field, for example, Name, and it's going to have a value of Test Account, you'll follow the syntax throughout, it's pretty straightforward. BillingCity going to choose a city, Portland. If we have a custom field like Category, the custom field name remember always has the __c attached to the name. So we're going to put that here, and then we're going to give it the category name. The global constants that we specified earlier, that's where these start to…
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.
Contents
-
-
-
-
Basic test class for Apex code2m 56s
-
(Locked)
Test data creation and validation1m 51s
-
(Locked)
Naming convention: Test classes1m 24s
-
(Locked)
Initial test class modifications2m 54s
-
(Locked)
Coding example: Test utility11m 7s
-
(Locked)
Testing using a test factory1m 41s
-
(Locked)
Set global values for the test factory2m 33s
-
(Locked)
Set up a test factory2m 29s
-
(Locked)
Customize a test factory3m 4s
-
Testing with a test factory5m 46s
-
-
-
-