I've a batch class which identifies the users which are not added to list of chatter groups (CollaborationGroups) and adds them to the groups by creating collaborationGroupMember records.
In order to test this batch apex class, I've written a test class:
- Created three user records
- Created two collaborationgroups
- Schedule batch apex within Test.startTest() and Test.stopTest()
- Now when I'm doing assertion in the test class, it fails --> Using debug statements before and after (and also within) Test.startTest() and Test.stopTest() it seems that collaborationGroupMembers are not created at all i.e. the members are not added to the group
But from the debug statements of the batch apex, I could see that the collaborationGroupMembers were successfully inserted for those three user records without any error.
Am I missing something here, or is this behaviour due to test context?
Thanks in advance!