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

Coding example: Test utility - Salesforce Tutorial

From the course: Introduction to Test Classes in Salesforce

Start my 1-month free trial

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…

Contents