function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfLearner0201sfLearner0201 

Urgent : Code Coverage of onInstall

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. 



Best Answer chosen by Admin (Salesforce Developers) 
gautam_singhgautam_singh

Hi,

Please add "testmethod". This will give you the solution.

 

 


Important :

Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You

 

 

public static testmethod void TestPostInstallClass() {