I'm writing some test cases for a custom class that interacts with a custom LWC that requires fields from SF contacts. I'm attempting to load test data from a static resource using Test.loadData as shown below:
@isTest(SeeAllData=false)
public static void getClientVaultTestOne(){
List<sObject> testContacts = Test.loadData(Contact.getSObjectType(),'TestData');
System.assert(testContacts.size() == 7, 'Error Loading Test Data');
Contact testContact = null;
for(sObject obj : testContacts){
Contact c = (Contact)obj;
if(c.FirstName.contains('Jones')){
testContact = c;
break;
}
}
System.debug('Test Contact: ' + testContact);
Test.startTest();
Test.setMock(HttpCalloutMock.class, new ClientVaultCalloutMock());
List<Map<String, Object>> clientFiles = DashboardController.getClientVault(testContact.Id);
Boolean testValid = true;
if(clientFiles.size() < 1){ testValid = false; }
for(Map<String,Object> element : clientFiles){
if(element.isEmpty()){
testValid = false;
}
}
System.assert(testValid, 'getClientVaultTestOne Failed');
Test.stopTest();
}
But for some reason this isn't exactly working. Salesforce is giving me a weird Exception when I try to run this test:
System.UnexpectedException: No more than one executeBatch can be called from within a test method.
Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.
External entry point 3564
I haven't been able to find cases of this happening elsewhere on the internet, and I'm following Salesforce documentation to the best of my ability but this is what I'm greeted with.
Any ideas on what I should change?