You need to sign in to do that
Don't have an account?
Kyo
Update CodeCoverage in TestClass
Test Class is not full loop . it's problem 1 line in Testclass
Coverage is 85% now
trigger ChangeStatusinOBC on Out_Bound_Call_List__c (Before insert,Before Update) { // You can change status equal Complete when RelatedList OB Contact status all Complete set<ID> setOBLID = new set<ID>(); for(Out_Bound_Call_List__c OBL : Trigger.new){ setOBLID.Add(OBL.ID); } // Add id for Query List<OutBound_Contact__c> lstOBC = [Select id from OutBound_Contact__c where Out_Bound_Call_List__c in : setOBLID]; // Query OutBound Contact List System.debug('Error SOQL'); for(Out_Bound_Call_List__c OBL : Trigger.new){ if((lstOBC.size() != OBL.Count_Complete__c) && lstOBC.size() != 0 && OBL.Status__c == 'Completed'){ Trigger.new[0].Status__c.AddError('Status in OutBound Contact all not equal to contacted'); }// Set Error in Field Status } }
a problem line :
if((lstOBC.size() != OBL.Count_Complete__c) && lstOBC.size() != 0 && OBL.Status__c == 'Completed'){
@isTest private class TestChangeStatusinOBC { static testMethod void myTest() { Out_Bound_Call_List__c OBL = new Out_Bound_Call_List__c(); OBL.Name = 'Test'; insert OBL; OutBound_Contact__c OBC = new OutBound_Contact__c(); OBC.Out_Bound_Call_List__c = OBL.id; OBC.Status__c = 'Contacted'; insert OBC; update OBC; Out_Bound_Call_List__c OBL1 = new Out_Bound_Call_List__c(); OBL.Name = 'Test'; OBL.Status__c = 'Completed'; test.startTest(); Try{ insert OBL; update OBL; } catch (Exception e) { System.Debug('Status in OutBound Contact all not equal to contacted'); } test.stopTest(); } }
Thank you so much.
Here is your test class
Let me know if any issues in it.
Thank for Answer but error change after edit Test class
Trigger.new[0].Status__c.AddError('Status in OutBound Contact all not equal to contacted');
and Field OBL.Count_Complete__c not writeable because Type Rollup summary
Thank you so much.
Ok I was not aware it is a rollup sumary field., try this , if it does not work please let me know what does this rollup summary field Count_Complete__c represents.
I'm edit Test class from ex.
//OBL.Count_Complete__c = 1;
but error hilight
Trigger.new[0].Status__c.AddError('Status in OutBound Contact all not equal to contacted');
I can not fix it.
Thank you.