You need to sign in to do that
Don't have an account?
Trigger test coverage
Hi..It may sound silly but this is my trigger.I have written a test class for this.It shows all the values in debug log.But still trigger test coverage is 0%
Any help please.
I have fedex application installed in my org.when i create a shipment and ship it,it generates a master tracking number.
Due to security issues i created a custom object and a trigger to copy tracking number in to my custom field on custom object.
trigger shippinginfoupdate on zkfedex__Shipment__c (after update) {
List<customobject__c> shipList =new List<customobject__c>();
for(zkfedex__Shipment__c zfs :trigger.new){
customobject__c s1 =new customobject__c();
if(zfs != null){
s1.Tracking_Number__c = zfs.zkfedex__MasterTrackingId__c;
s1.Ship_Date__c = zfs.zkfedex__ShipDate__c;
s1.Lead__c = zfs.zkfedex__RecipientLead__c;
s1.FedexShipment__c = zfs.id;
shipList.add(s1);
}
}
insert shipList;
}
Thanks in advance!!!
Hi,
Could you please try below test class. Actually your trigger will run on update of record, where as in your test class you have not updated recorded, but inserted only. I have made amendmant in your test class.
Let me know if you have any question.
Happy to help you!
All Answers
Hi,
Please share your test class which you have written, so that I can make amendmant into that.
@isTest(seealldata=true)
public class test_shippinginfoupdate {
public static testMethod void mytestmethod(){
Lead l = new Lead(LastName='Test',Company='Test');
insert l;
zkfedex__Shipment__c fed = new zkfedex__Shipment__c();
fed.zkfedex__RecipientStreet__c ='8-6-237,Stacy road';
fed.zkfedex__MasterTrackingId__c ='1234567898764';
fed.zkfedex__RecipientLead__c =l.id;
insert fed;
Shipping_Info__c s1 =new Shipping_Info__c();
s1.Lead__c =fed.zkfedex__RecipientLead__c;
s1.FedexShipment__c =fed.id;
s1.Tracking_Number__c = fed.zkfedex__MasterTrackingId__c;
insert s1;
}
}
Hi,
Could you please try below test class. Actually your trigger will run on update of record, where as in your test class you have not updated recorded, but inserted only. I have made amendmant in your test class.
Let me know if you have any question.
Happy to help you!