1

I just created this simple class:

    global class HelloSandboxWorld implements SandboxPostCopy {
  global void runApexClass(SandboxContext context) {
      System.debug('Hello Tester Pester ' + context.organizationId() + ' ' + context.sandboxId() + context.sandboxName());
    }
  }

Now I want to debug it, I opened an anonymous execution window and typed the following:

HelloSandboxWorld s = new HelloSandboxWorld();

I executed the code, opened the logs, but nothing appears under 'Debug'.

Please help.

0

You will find it easiest to Debug this class from a Test class.

E.g.

@isTest
public class HelloSandboxWorld_test {

    @isTest
    public static void testPostCopy(){
        // The ID's from these Accounts will standin for the actual Orgs 
        // as we can't create those   
        Account sandbox = new Account(
            Name = 'sandbox'
        );

        insert sandbox;

        Test.startTest();

        Test.testSandboxPostCopyScript(
            new SandboxDataProvider(), 
            UserInfo.getOrganizationId(), 
            sandbox.Id, 
            'TestSandboxName'
        );      

        Test.stopTest();   
    }
}

You can capture the Debug log as usual when the test case is run.

0

Call the runApexClass function with the instance variable of your class.

Eg:-

HelloSandboxWorld s = new HelloSandboxWorld();
SandboxContext context = new SandboxContext();
s.runApexClass(context);
2
  • Tried your suggestion, got the following error: Type cannot be constructed: SandboxContext
    – Json
    Dec 14 '16 at 11:54
  • Can you add more code here? That is just an example not actual working code
    – Amjad khan
    Dec 15 '16 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.