• sfLearner0201
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi , 

Can anyone help me cover this picece of code. I am trying such that whenever someone installs my managed package a schdeule runs which calls a method to execute.

My Code is below : 

global without sharing class PostInstallClass implements InstallHandler {

    //public system.Version cotext{get;set;}
    global void onInstall(InstallContext context) {
        
          if(context.previousVersion() == null) {
        //cotext = System.requestVersion();
        ScheduleCodeUpdate objhclass = new ScheduleCodeUpdate();
        system.schedule('ScheduleclassEveryhour', CRON_STRING , objhclass); 
        }
    } // execute 
}// class PostInstallClass

 

and my Test Class is : 

@istest
public without sharing class TestPostInstallClass {
    
    public static void TestPostInstallClass() {
        
        PostInstallClass postinstall = new PostInstallClass();
        Test.testInstall(postinstall, null);
       // Test.testInstall(postinstall, postinstall.cotext  , false);
        
    }
}

 
Code Samples to cover Schedule Code of Managed Package are highly appreciated.

Thank You.