I'm writing a component to handle CampaignMembers, and it will be common to have more than 10k CampaignMembers. So I'm writing my SOQL to get the campaignMembers in batches of 10K, appending them to the list.
Now, I'm working on a unit test, so I want to generate more than 20K Leads, and then more than 20k corresponding CampaignMembers. (I want at least 3 SOQL batches to make sure the logic works.)
I searched here and elsewhere and couldn't find a good way to circumvent the 10K DML rows limitation in a test. So now, I'm trying to do it with test.loadData(). So far, I'm getting System.UnexpectedException -- so I think I'm probably running into the same 10k limit.
I'm thinking I'll add a dynamic batch size to the class, so if Test.IsRunningTest(), batch size will scale down to 100 in my dynamic SOQL and in my forLoop.
Any ideas of how to test this otherwise?