+ Start a Discussion
Sarah RobertsonSarah Robertson 

Invokable class unit tests issue

HI Wondering if anyone can help a newbie here in trouble !  

I'm trying to write a test class for this class which uses an ivokable method callled by process builder. I'm getting the following error on the test class can anyone direct me as to where i'm going wrong ? 
: Compile Error: Method does not exist or incorrect signature: void invokeapexcallout(List<String>, List<Id>) from the type MakeApexCallout at line 29 column 28

Here is my class : 

public class MakeApexCallout {

  @InvocableMethod(label='callout')
   public static void invokeapexcallout(list<Account> acc) {
     Futureapexcallout.apexcallout(acc[0].Siret_Number__c,acc[0].Id);
   }
}


My Test Class 

@IsTest

public Class MakeApexCalloutTest {

static testMethod void CallOutTest() {

   

// Create Account
          
        Account acc = new Account();

        acc.Name = 'test Account';

        acc.Siret_Number__c = '42097142600035';
        
        insert acc;
            
           List<Id> AccountIds = new List<Id>(); 
           AccountIds.add(acc.Id);
           List<String> SiretNumbers= new List<String>();
          
          SiretNumbers.add(acc.Siret_Number__c);


            Test.startTest();

         
           MakeApexCallout.invokeapexcallout(SiretNumbers, AccountIds);
            Test.stopTest();

}}


 
Best Answer chosen by Sarah Robertson
GauravendraGauravendra
Hi Sarah,

The main invokeapexcallout() method is only accepting one parameter i.e. List<Account> but from your test class, you are calling it with two different arguments. Thats the issue.
When you are creating the account, add that in List<Account> and pass that list as argument in test class.

Hope this helps!

All Answers

GauravendraGauravendra
Hi Sarah,

The main invokeapexcallout() method is only accepting one parameter i.e. List<Account> but from your test class, you are calling it with two different arguments. Thats the issue.
When you are creating the account, add that in List<Account> and pass that list as argument in test class.

Hope this helps!
This was selected as the best answer
Sarah RobertsonSarah Robertson
Getting there ! Thanks Gauravendra

so my test class : is giving me this error. I'm guessing i need to make a mockhttpcallout class : 
Methods defined as TestMethod do not support Web service callouts


@IsTest

public Class MakeApexCalloutTest {

static testMethod void CallOutTest() {

   List<Account> Accounts = New List <Account>(); 

// Create Account
          
        Account acc = new Account();

        acc.Name = 'test Account';

        acc.Siret_Number__c = '42097142600035';
        
        insert acc;
        Accounts.add(acc);    
           List<Id> AccountIds = new List<Id>(); 
           AccountIds.add(acc.Id);
           List<String> SiretNumbers= new List<String>();
          
          SiretNumbers.add(acc.Siret_Number__c);


            Test.startTest();

         
           MakeApexCallout.invokeapexcallout(Accounts);
            Test.stopTest();

}}

 
Sarah RobertsonSarah Robertson
Thank you so much !! it is working now i added the section of code from here to the HTTP call out mock class :)