I have created a Installhandler class for the custom setting object and I would like to test whether it works properly when the installer installs it? How can I accomplish this? Since this is the first time I am creating the package I would like to know the steps for achieving the same? As of now I have created a separate Org and passed the install handler class and its associated test class into it..

How can I verify whether the handler script is running properly and the records of custom settings are properly inserted into it? Any thoughts please. Thanks.

2 Answers 2


Here is one (of many) test methods for an install handler in our code:

static void testAdls() {

    // Clear to make sure the value is set by the install handler
    Options__c cs = Options__c.getInstance();
    cs.ActivitiesOfDailyLiving__c = null;
    upsert cs;

    Test.testInstall(new ClaimsInstallHandler(), new Version(8, 5));

    // Custom setting is correctly defaulted
    System.assertNotEquals(null, Options__c.getInstance().ActivitiesOfDailyLiving__c);

This makes use of the Test.testInstall method.

  • Thanks @Keith. Will this work both in managed as well as unmanaged? Do I need to install created Managed Package in any new org to test this whether this is working or not? Commented Jan 4, 2016 at 16:11
  • @Pri I can't confirm that it works for unmanaged packages but assume it would. Though as unmanaged packages can't be updated the version detail is moot. The unit test is just like any other unit test and does not require any package installation.
    – Keith C
    Commented Jan 4, 2016 at 16:21
  • Yea Understood and [email protected] have created the test class as you have mentioned but what I would like to check is whether the records have been inserted or not.For example when we pass the custom setting object to a separate org only the schema of that particular object will be passed.But records will be inserted only after this handler script runs.Right?How can I check manually that records have been inserted for that object? Commented Jan 5, 2016 at 6:47
  • @Pri You can manually check by going to Setup -> Develop -> Custom Settings then click "Manage" for your setting and there should be a "Default Organization Level Value" (providing your install handler creates that by making the setting have SetupOwnerId = UserInfo.getOrganizationId() o nthe object it upserts.
    – Keith C
    Commented Jan 5, 2016 at 8:20
  • Sorry to repeat the same question again.Even after using getOrganisationId I couldn't see records of the custom settings object.Can this be viewed only after creating and installing package? Commented Jan 5, 2016 at 9:21

You have to specify your install handler in your package, as described here. If you haven't done this before, you need to configure this and create a new package.

You mention a test unit class: I assume that it covers the behaviour of your install handler, and asserts that the custom settings have been instantiated. You can do this by calling the Test.testInstall () method.

When you have all of the above, you can also do a smoke test by installing the package in a fresh developer org and then verifying that your settings have been created.

You must log in to answer this question.

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