Friday, August 10, 2012

Event Test Class:

Event Test Class:
This example  how to write simple test class on event.The purpose is i have a trigger after insert an event and class associated with it.To deploy the trigger need code coverage so it looks like this

@isTest(seealldata=True) private class testSendAnEmail{     static testMethod void testSendAnEmail(){          // setup your data by creating a user, and your contacts                         Account acct = new Account( Name = 'Test Account' );                         insert acct;                           Contact contact = new Contact( FirstName = 'Test', LastName = 'User', AccountId = acct.Id );                         insert contact;                           DateTime dt1 = DateTime.valueOf('2007-01-01 2:35:21');                           // create the event and insert it to fire the trigger                                                  Event evnt = new Event( subject='other',ownerid='00530000004xeYz',DurationInMinutes=15,ActivityDateTime=dt1);                         insert evnt;                                                                                                           } }

No comments:

Post a Comment