You need to sign in to do that
Don't have an account?
jhansisridhar_2011
URGENT : Regarding If Condition in test class for trigger.
Hi All,
It's Very urgent !!
Can anyone help to write a test class for below code;
Need to satisfy if condition.I created 2 records of an object with Akreos_MIL__c = 220 and Akreos_MIL__c = 210. but, it;s not working increase code coverage.
if (trigger.OldMap.get(pv.Id).Akreos_MIL__c != pv.Akreos_MIL__c) {
.....
...
....
}
Thanks in Advance.
Hi,
I want to know about the condition which you have define while writing your trigger. Like after insert, before insert, after update, before update. What condition are you using inside the trigger? If you are using update also then no need of creating the two records. You can simply update the old record.
All Answers
Hi,
Can you please post your trigger by mentioning code which you are unable to cover?????
Hi Navatar,
Thanks for replay :)
Please find below code I wrote in trigger.I need write a test class to increase code coverage .
map_monthlyImplantDetails.put(oCompProduct.Id, oCompProduct);
if (map_RecordType.get(pv.RecordTypeId) == 'APACSU Sales Planned') {
oCompProduct.Current_Total_Implantations__c = pv.Imported_Foldable_Implant__c;
if (trigger.OldMap.get(pv.Id).Akreos_MIL__c != pv.Akreos_MIL__c) { // here if condition is not statisfied // oCompProduct.AKREOS_MIL__c = (oCompProduct.Akreos_MIL__c != null ? oCompProduct.Akreos_MIL__c : 0) - (trigger.OldMap.get(pv.Id).Akreos_MIL__c != null ? trigger.OldMap.get(pv.Id).Akreos_MIL__c : 0) ;
oCompProduct.AKREOS_MIL__c = oCompProduct.Akreos_MIL__c + (pv.Akreos_MIL__c != null ? pv.Akreos_MIL__c : 0);
}
}
if (trigger.OldMap.get(pv.Id).AKREOS_AO__c!= pv.AKREOS_AO__c) {
oCompProduct.AKREOS_AO__c= (oCompProduct.AKREOS_AO__c != null ? oCompProduct.AKREOS_AO__c: 0) - (trigger.OldMap.get(pv.Id).AKREOS_AO__c!= null ? trigger.OldMap.get(pv.Id).AKREOS_AO__c: 0) ;
oCompProduct.AKREOS_AO__c= oCompProduct.AKREOS_AO__c + (pv.AKREOS_AO__c != null ? pv.AKREOS_AO__c: 0);
}
Thanks in advance.
Hi,
I want to know about the condition which you have define while writing your trigger. Like after insert, before insert, after update, before update. What condition are you using inside the trigger? If you are using update also then no need of creating the two records. You can simply update the old record.
Hi Navatar,
it's working .. Thanks a lot !!!!!!!!