You need to sign in to do that
Don't have an account?
Snehal Gaware 15
test class for before update trigger on custom object
Hi, i need help to write test class for following trigger.
Thanks in advance.
trigger UpdateProblemTaskOwner on SC_Problem_Task__c (after insert, after update, after delete,before update) { if (Trigger.isBefore && Trigger.isUpdate) { for(SC_Problem_Task__c pt : Trigger.new) { List<Group> qid = [select Id from Group where Name = : pt.Assignment_Group__c and Type = 'Queue']; for(Group g : qid) { pt.OwnerId = g.id; System.debug('updated'); } } } }
Thanks in advance.
@isTest
private class testUpdateProblemTaskOwner
{
@isTest
public void theTriggerTest()
{
List<SC_Problem_Task__c> testData = new List<SC_Problem_Task__c>();
// Now create some data and put them in the list
// Do fake instert of them and then fake update make sure that the fields you check in your SOQL have proper values
// and done...
}
}
By the way yout trigger will reach governer limit very fast ... you shouldn't have SOQL in for loop. Get all of the group records and work with them instead of querrying for them in for loop.