0

I am receiving an error :

'Error: Compile Error: Method does not exist or incorrect signature: Test.testInstall(PostInstallClass, NULL) at line 5 column 7'

for the below test class.

Code:

@isTest
public class testInstaller{
    public void testPostInstallClass() {
        PostInstallClass postinstall = new PostInstallClass();
        Test.testInstall(postinstall ,null);
        Test.testInstall(postinstall, new Version(1,0), true);
    }
}

class:

 global class PostInstallClass implements InstallHandler {
   global void onInstall(InstallContext context) {
// If installing for the first time, setup data.
    if (context.previousVersion() == null) {
    // load Static Resource containing JSON and to deserialize it and save as records.
        StaticResource someObjectStaticResource = [select Body from StaticResource where Name = 'PocSFTF_CustomSet__c'];
        List<PocSFTF__SFTFPOC__c> someObjects = (List<PocSFTF__SFTFPOC__c>) JSON.deserialize(someObjectStaticResource.Body.toString(), List<PocSFTF__SFTFPOC__c>.class);
        insert someObjects ; 

        StaticResource HistoricD= [select Body from StaticResource where Name = 'PocSFTF_HistoricData__c'];
        List<PocSFTF__SFTF_Historic_data__c> HistData= (List<PocSFTF__SFTF_Historic_data__c>) JSON.deserialize(HistoricD.Body.toString(), List<PocSFTF__SFTF_Historic_data__c>.class);
        insert HistData;
    }
}
}

Kindly help me with this issue.

  • Can you check API version of the class saved? That has been added recently, so ensure that there is new api version for apex class (like 37) – kurunve Sep 12 '16 at 8:42
  • @kurunve Its 37 – Lolita Sep 12 '16 at 9:15
1

I managed to reproduce this by using a class that does not implement InstallHandler.

Make sure that your PostInstallClass is explicitly implementing it:

public class PostInstallClass extends InstallHandler {
    public void OnInstall (InstallContext context)
    {
        // do stuff here...
    }
}

The extends InstallHandler part is key here

Edit: after your answers, I see that the class implements the right interface. I have been unable to reproduce your error. At this point I would try this:

  • Add the @isTest annotation to your method
  • Comment out the failing line and see if the next line fails as well. It could be a case of the Apex compiler not being able to assign a type to that null value.
  • Swap the lines around
  • Extract a variable (Version myVersion = null;) and supply it to the Test.testInstall method.
1

Many times when a custom Apex Class "Test" is created, you might see this problem since standard System.Test class is hidden by custom apex class "Test".

Try to replace lines

    Test.testInstall(postinstall ,null);
    Test.testInstall(postinstall, new Version(1,0), true);

with

    System.Test.testInstall(postinstall ,null);
    System.Test.testInstall(postinstall, new Version(1,0), true);

If issue is resolved then you have the problem described. Try to search for "Test" unmanaged class in your organization.

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.