I generate a number of different email notifications from Cases, with variations depending on Account location, for example. They've morphed from basic workflow email templates in order to gather details from Assets, Contacts, etc., and I've been working in standard processes/methods 'cause maintenance is hell.
I've built generic utility classes before, and am trying to create one specifically for these notifications, but if there's a better approach now's the time.
My Utils class is defined like this:
global class Utils {
public static List<Contact> getActiveContactsByAccountIdRTId(Set<Id> accountIds, Set<Id> rtIds) {
List<Contact> results;
results = [some query];
return results;
}
}
It made sense to me to separate the notification methods and treat them the same way, but a) I'm getting that 'cannot call test methods in non-test context' error, and also b) Should I take a moment (or several) and create an abstract class for the notification template so to speak, and build out any customizations in the derived classes?
I have a good example to work from which uses SObject recordtypes to determine which path to follow, and I'll need to work out a different set of criteria for routing these Cases through.
@IsTest
ortestMethod
to solve the problem in the title. The non-test code must not invoke any test method. – Keith C Jan 17 '18 at 17:28