Test Class for Custom Objects for Versions Older Than 10
//test class for SuperRoundRobin triggers on custom objects (and standard objects beyond the out-of-the-box Lead, Account, Contact, Opportunity and Case)
//if you are required to put customer specific configuration into this test class, there will be a comment starting '//Config required:' in the preceding line telling you what to do
@isTest
private class SRRTriggerTest {
@isTest
static void testSRRTrigger() {
//Config required: objectType is the API Name for the object you created the trigger on. e.g. MyCustomObjectc or Campaign. This example is for Campaign.
String objectType = 'Campaign';
//Config required: objectFieldName: select a field from the object that this test will create a MatchRule with. Easiest is to use a String field like Description
String objectFieldName = 'Description';
//Config required: objectFieldValue: the value in the objectFieldName that will cause a positive match. If you set the objectFieldName to 'Description' then put 'DescriptionValue' here.
String objectFieldValue = 'DescriptionValue';
leadassistMatchGroupc mg = leadassist.TestDataFactory.setupTestAndReturnMatchGroup(objectType,objectFieldName,objectFieldValue);
Decimal leadcountbefore = mg.leadassistleadcountc;
//Config required: this line of Apex code creates a new record of the object you created the trigger on. This test example is for the Campaign object. Remember to include any required fields, and the matching field you set above (Description in this example)
Campaign newRecord = new Campaign(Description='DescriptionValue', Name='Example Campaign', Status='Planned', UseRoundRobinc='TRUE');
Test.startTest();
insert newRecord;
Test.stopTest();
leadassistMatchGroupc mgAfter = select leadassistleadcountc from leadassistMatchGroupc where Id = :mg.Id;
Decimal leadcountafter = mgAfter.leadassistleadcountc;
System.assert(leadcountafter == leadcountbefore+1);
}
}