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.
Set global values for the test factory - Salesforce Tutorial
From the course: Introduction to Test Classes in Salesforce
Set global values for the test factory
- [Instructor] As we're getting ready to start fleshing out the details of our test factory, there's a few things that we need to do in advance. First one we need to define some global constants. These are values that are not going to change in our org, that we need to have available to us as we're creating the test, and creating the various objects in our test factory. First thing we're going to look at is record types. Obviously the more complex the org is the more record types you're going to have, and you're going to have code that's dependent upon those record types. So we're going to need to be able to test those. Instead of having every test method query for those particular record types, we're going to use them as global constants. And as you can see here in line 5 through 7, we have set up a customer account. In that customer account we're going to query and return the record type for the customer. We also have one for business, so in our org we have basically two record…
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
-
-
-
-