+ Start a Discussion

How to write a test case for group events?

Trying to write a test case for creating a group event however the child events for the invitee's do not get created.


When execution the code below in the debug console it works as expected and creates the child Event record for the invitee,  however when running in a test case the child event record does not get created.


 I Also tried checking for the events after a call to the Test.startTest() and it did not work either.


//Add Event
Event e = new Event(ActivityDateTime=DateTime.Now()+1, subject='Apex Event Demo', whatid='001............', DurationInMinutes=60);
insert e;	

//Add Invitee to event
EventRelation er1 = new EventRelation(EventId = e.id,  RelationId='005............');
insert er1;


Neha LundNeha Lund

Just try putting RelationId as Id of the contact...


No dice,  a contact or user in the relationId still does not create the invitee event records in a test case,