function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
indranily81indranily81 

group member insertion order blocking data preparation in test class


Hi ,

I am facing a weird issue while preparing test data. Below are the steps mentioned what I did.

 

The test data is prepared in the below order.

1. created test users first and inserted into Salesforce.
2. created test group and inserted into salesforce.
3. created group members and inserted into salesforce.
4. created account and inserted into salesforce.
5. created opportunity and inserted into salesforce.


what I am facing is some of my test data is not being created. In this case below assertions failed due to zero rows came
out.

 

System.assertEquals(1, [Select count() from Account where LastName =: 'Test ACC99$$']);
System.assertEquals(1, [Select count() from Opportunity where Name ='TEST OPP99$$']);

 

The moment I break step 3 into two parts and just create the group members in step 3 and insert them after step 5 then the above assertion is working correctly. I am not able to understand how groupMember insertion order is impacting test account and opportunity record creation.

 

Has anyone in the forum faced similar issue ?

 

Thanks
Indranil