
6 réponses
First of all, I would really disadvice to write more than one trigger related to the same object (Standard or Custom) because Salesforce never guarantee the order of execution. Maybe first time Trigger1 is executed before Trigger2 and next time Trigger2 is executed before Trigger1. Regarding your question. Using your TestClass and having this code as an example: //Class code
public with sharing classA
{
public static void method1(myCustomObject__c myObj)
{
...
}
public static void method2(myCustomObject__c myObj)
{
...
}
}
And your trigger
Then only method1 would be covered and method2 will not be covered, so % would not be 100%If your trigger is://Trigger code
trigger myTrigger on myCustomObject__c (before insert)
{
for(myCustomObject__c myObj : Trigger.new) //Remember bulkification
{
classA.method1(myObj);
}
}
Then your class would be fully covered by the trigger.If you also have this class//Trigger code
trigger myTrigger on myCustomObject__c (before insert)
{
for(myCustomObject__c myObj : Trigger.new) //Remember bulkification
{
classA.method1(myObj);
classA.method2(myOjb);
}
}
But you have above trigger, this second class would not be called there so this class would not be covered at all.Does it make sense?//Class code
public with sharing classB
{
public static void method3(myCustomObject__c myObj)
{
...
}
}