You need to sign in to do that
Don't have an account?
sandeepathadu
help for test case
plz help me how to write test case for my trigger
trigger Dev_update_Appt on Appointment__c(after update) { public list<appointment__c> apps {get;set;} public list<appointment__c> apps5 {get;set;} apps5 = new list<appointment__c>(); apps = new list<appointment__c>(); Map<ID , appointment__c> mapAppiontment = new MAP<ID , appointment__c>([select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c, Dev_Parent_Appt__c from appointment__c where id in: trigger.old]); List<appointment__c> listApp = new List<appointment__c>(); MAP<ID , List<appointment__c>> mapAPPID_List = new MAP<ID , List<appointment__c>>(); for(appointment__c appObj : [select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c,Dev_Parent_Appt__c from appointment__c where Dev_Parent_Appt__c in: mapAppiontment.keyset()]) { if(mapAPPID_List.containskey(appObj.Dev_Parent_Appt__c)) { listApp = mapAPPID_List.get(appObj.Dev_Parent_Appt__c); } else { listApp = new List<appointment__c>(); } listApp.add(appObj); mapAPPID_List.put(appObj.Dev_Parent_Appt__c , listApp); } for(Appointment__c o:Trigger.old ) { if (Trigger.isUpdate) { appointment__c app1 = mapAppiontment.get(o.id); List<appointment__c> app = new List<appointment__c>(); if(mapAPPID_List.containsKey(app1.id)) app = mapAPPID_List.get(app1.id); for(appointment__c ap:app) { ap.branch__c=app1.branch__c; ap.Doctor__c=app1.Doctor__c; ap.Appt_Date__c=app1.Appt_Date__c; apps.add(ap); } } } update apps; }
my test case i have written i am getting 60 percent
@isTest private class updateclass { static testmethod void TestController() { Staff__c s1 = new Staff__c(); s1.name='Rahul'; s1.Mobile__c='9849098490'; insert s1; Branch__c b = new Branch__c(); b.Name = 'Test'; b.Region__c = 'Market Price'; insert b; Account a = new Account (); a.LastName = 'Test'; a.Branch__c = b.id; a.PersonMobilePhone = '9550412970'; insert a ; Appointment__c app2 = new Appointment__c(); app2.account__c=a.id; //app2.Dev_Parent_Appt__c=app1.id; app2.from__c='6'; app2.from_min__c = '00'; app2.Appt_AM_PM__c='PM'; app2.Appt_Date__c=date.ValueOf('2011-05-21'); app2.Appt_Hour__c='9'; app2.Appt_Minute__c='80'; app2.RecordTypeid='012N0000000CgZ2'; app2.Branch__c=b.id; app2.to_Min__c='40'; app2.to__c='7'; insert app2; update app2 ; } }
plz help me to resolve my issue
Hi,
I remember this trigger.
Let me try with test class as well
All Answers
Hi,
I remember this trigger.
Let me try with test class as well
thank u once again i have live now
i have seen u r blog it is really usefull for developers like me plz keep doing many more like these which will help us very much
thank you sir
with regards
sandeep sharma
Your welcome sandeep