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
Rakesh Muppiri 12Rakesh Muppiri 12 

Test.setFixedSearchResults is not a valid method, in Test Class

I have written test class, earlier it was working fine. Now to enhance it I have edited class and when i am trying to save it is throwing error like'Test.setFixedSearchResults is not a valid method or not valid signature'.

Please help me.
Igor Androsov 5Igor Androsov 5
While asking such detailed question please add your Test Source or at least section that methods that failed. Otherwise1.  Otherwise, it's just my guess
1. Check your API version and ensure that SOSL Test.setFixedSearchResults have same set of parameters if any to match method signature
2. Check test class syntax before error line and see if any missing bracket or quote you add during edit
Rakesh Muppiri 12Rakesh Muppiri 12
@Igor,
Yeah I have checked everything, there is no braces missing. Its simply edit and save the version also same.
Here is the code snippet.
testData() - Creates all necessary data
initializeVariable() - setting up Ids to be available for SOSL 
@isTest
public class InteractionLauncherAgentSearchTest{
     
     //Create all necessary Object records in this method
     @testSetup 
     static void testData() {
         
         // Create custom setting
         UTIL_TestMethods.createRecordTypeCustomSettings('Account Record Types', 'EA_Agency,IA_LBE,IA_Sub');
         UTIL_TestMethods.createRecordTypeCustomSettings( 'Contact Record Types', 'Agency_Staff');
         
         // Create Agency
         Account acc = UTIL_TestMethods.createAccount('testagencyname', 'EA Agency');
         
         // Create Agency
         Account accwithACAT = UTIL_TestMethods.createAccount('testagencynameACAT', 'EA Agency');
         accwithACAT.Agency_Code__c = null;
         accwithACAT.ACAT_AOR__c = '123456';
         update accwithACAT;
         
         UTIL_TestMethods.createProducerCode('123456', accwithACAT.Id, 'Active');
         
         // Create Agent
         Contact con = UTIL_TestMethods.createContact('testfirstname', 'testlastname', 'Agency Staff', acc.Id);
         // Create Agent
         Contact conACAT = UTIL_TestMethods.createContact('testfirstname', 'testlastname', 'Agency Staff', accwithACAT.Id);
         
         // Create Agent
         Contact conNoACAT = UTIL_TestMethods.createContact('John', 'Macinto', 'Agency Staff', acc.Id);
         
     }
     
     // This method initializes all common variable that needed for every test method
     static void initializeVariable(){
         
         // Set the length number of records that we would use in SOSL
         Id [] fixedSearchResults= new Id[10];
         
         // Set Account id in SOSl result for Test class
         
         // Set ProductionCode id in SOSl result for Test class
         fixedSearchResults[0] = [SELECT Id FROM vlocity_ins__ProductionCode__c LIMIT 1].Id;
         
         Integer i = 1;
         // Set Contact id in SOSl result for Test class
         for(Contact con :  [SELECT Id FROM Contact]){
             fixedSearchResults[i] = Con.Id;
             i++;
         }
         // Set Contact id in SOSl result for Test class
         for(Account acc :  [SELECT Id FROM Account]){
             fixedSearchResults[i] = acc.Id;
             i++;
         }
         
         // Set ProductionCode id in SOSl result for Test class
         Test.setFixedSearchResults(fixedSearchResults);
     }
}

 
Rakesh Muppiri 12Rakesh Muppiri 12
Invalid signature error