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.

Best practices with test class

Best practices with test class - Salesforce Tutorial

From the course: Introduction to Test Classes in Salesforce

Start my 1-month free trial

Best practices with test class

- [Instructor] Now that we've completed our initial test classes with either a test utility or a test factory, let's review and look at those best practices that we want to do with test classes. First thing, system asserts, we definitely need to use system asserts. We've got to have some way of validating that our code is actually doing what we expect it to do. As we've already covered, test factories, my preferred method is test factories over test utilities. I find that orgs that are using test factories stay consistent with how they're creating the data, the data is all created in one location, all the defaults are set in one location. Test utilities, for whatever reason, people start to stray from using the test utility, they start creating accounts by just doing a new account in their test classes or creating a contact by doing a new contact in their test classes, and no longer using the test utilities. So test factories is another important thing to stick with. We'll look a…

Contents