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.

Static resources

Static resources - Salesforce Tutorial

From the course: Introduction to Test Classes in Salesforce

Start my 1-month free trial

Static resources

- [Instructor] Another best practice could be using Static Resources to actually set up your test data. As I mentioned earlier, since this is a method in which, beginning admins and intermediate level admins, can sometimes have a challenge with if they have to update the data. I have tended not to use this. But, if you want to use static resources, the way you can do that, is you use a method called Test.loadData the name of your object, for example, Account, or Contact. And then the specific name of the Static Resource, and this would be the name that you'd given this when you've loaded it into your system. The basic process of creating a static resource, is you create a .csv file, that has your records. So, you would do each one individually, you would do Account, a .csv file for Accounts. You would do a .csv file for Contacts, .csv file for Opportunities, and so on. Now, part of doing this is, because you've got to relate these records to each other. This is where it can become…

Contents