I have a sandbox deploy script that works fine for setting environment variables but fails to create test data that I always need. If I run the data insert methods manually, they work fine - but the deploy script seems to skip those methods. Is this an issue with calling static methods or does SandboxPostCopy intentionally block SOQL inserts?
The following is my main function:
// Main deploy script
global void runApexClass(SandboxContext context) {
// Set org to dev
Server__c srv = Server__c.getOrgDefaults();
srv.Environment__c = 'dev';
srv.Disable_Rules__c = true;
upsert srv;
createDummyAccountContact();
createTestLeads(10);
createTestLoans(4);
}
You need to do it like below SandboxCreateBulkTestData cls = new SandboxCreateBulkTestData();
Test.testSandboxPostCopyScript(cls, // the instantiated class that implements the SandboxPostCopy interface
UserInfo.getOrganizationId(), // context org ID
UserInfo.getOrganizationId(), // context SandboxID
'sandbox');