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 - Salesforce Tutorial
From the course: Introduction to Test Classes in Salesforce
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…
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
-
-
-
-