Apex Test Utility Class

When programming on the Salesforce platform in order to deploy anything to production you need to have a “Apex Test Class” that runs over 75% of the code without errors.

To make this task as painless as possible you should create whats called a Apex Utility class to use with test classes.

Let’s say you have a trigger that can be 100% covered with just an insert of an account record.
We can achieve that with this Utility Class:

Now in your test class you could just do this (by invoking the utility class) and cover an account and lead trigger:

 

Add Comment