You need to sign in to do that
Don't have an account?
MS123456
Can You Any One Pls Tell I am Writing Test Is it bulkify test cls
Hi Team Pls Help me is bulkify Or not Test Class........
@isTest public class eventTriggerContactTest { static testMethod void testMostRecentUpdation() { Contact objContact = new Contact(); objContact.LastName = 'TestCon'; objContact.FirstName = 'TestCon'; insert objContact; Event objEvent = new Event(); for(Integer i=0;i<=200; i++) { objEvent.Type = 'Consult'; objEvent.Description = 'Test Desc'; objEvent.whoId = objContact.Id; objEvent.Meeting_Type__c='Phone'; objEvent.Event_Status__c='Completed'; objEvent.Phone_Call_Type__c='Inbound'; objEvent.StartDateTime = System.today(); objEvent.EndDateTime = System.today(); objEvent.Subject = 'Test Event'; } insert objEvent; System.assertEquals(objEvent.Id, [SELECT Most_Recent_Event_Id__c FROM Contact WHERE Id =: objContact.Id].Most_Recent_Event_Id__c); Event objEvent2 = new Event(); for(Integer i=0;i<=200;i++) { objEvent2.Type = 'Consult'; objEvent2.Description = 'Test Desc'; objEvent2.Meeting_Type__c='Phone'; objEvent2.Event_Status__c='Completed'; objEvent2.Phone_Call_Type__c='Inbound'; objEvent2.whoId = objContact.Id; objEvent2.StartDateTime = System.today(); objEvent2.EndDateTime = System.today(); objEvent2.Subject = 'Test Event'; } insert objEvent2; System.assertEquals(objEvent2.Id, [SELECT Most_Recent_Event_Id__c FROM Contact WHERE Id =: objContact.Id].Most_Recent_Event_Id__c); update objEvent; } }
This is not bulkified. You are trying to insert 200 Event records but your code willl not work as you expexted because you are creating only one reference of Event object and and assigning field value in loop will overide to previos loop iterartion. You can follow below code snippet to insert more than one record.
Thanks
Banwari
Skype: bkevat92
Let us know if this will help you