From the course: Introduction to Test Classes in Salesforce

Value of test classes - Salesforce Tutorial

From the course: Introduction to Test Classes in Salesforce

Start my 1-month free trial

Value of test classes

- [Instructor] What exactly is the value of test classes? As a developer, a lot of times we think that the value of test classes is just Salesforce's way of torturing us. If we understand how Salesforce uses the test classes, it actually makes it easier to write and execute the test code. One of the things we want to do is we want to prove that our code is working. One of the ways that Salesforce uses test classes is, they execute all of the test code. They pay attention to all of the test classes that pass. They then release their new code that is running underneath our code. They then re-execute all the test code, again, only looking at the ones that passed on the first execution, that are now failing. This allows Salesforce to determine whether the current release that they're getting ready to do to our orgs is going to break our code or not. They're able to go through the failures, identify those failures, and determine, is it going to affect us? Now in some cases, it will, and it may be because something has changed, it may be because a security requirement has come out that we're going to have to change our code. But in general, if our test classes passed with the old code, they should also pass with the new code, and we should not see any failures. Understanding this allows us to write better test code. It gives us an incentive on how to write better test code because we actually understand why Salesforce is requiring it and how they're using it.

Contents