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.

2 Answers 2

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
    Commented Dec 14, 2016 at 11:54
  • Can you add more code here? That is just an example not actual working code
    – Amjad khan
    Commented Dec 15, 2016 at 12:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .