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.
Coding example: Test utility - Salesforce Tutorial
From the course: Introduction to Test Classes in Salesforce
Coding example: Test utility
at our AccountTriggerHandlerTest and how we go about creating the test code to test our AccountTriggerHandler. The first thing we're going to do is we're going to jump over to the TestUtility. So, we will have created this in advance, and this is the utility class that we're going to create where we create a method for each object values that must be set based on whatever current validation rules or workflows or anything else that we have on our org that's going to require us to have these values set. So, in this case, we set the name, the shipping and billing information. We're also going to provide a method here on line 25 where we can actually create an account with a specific record type. In some cases, our orgs will have two or three record types. Some orgs have a lot of different record types, and we want to be able to test the code based on the record type that's needed. So, we have to have another method that allows us to actually specify the record type that we would like 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
-
-
-
-