So, we have a Test Data Factory that creates many test Lead records. Some tests need inserted Leads with Ids, some do not.
I'm writing my Test Data Factory to reference a CSV file in Static Resources named 'testLeads'.
The problem is that Test.loadData(lead.sObjectType, 'testLeads');
will insert the records before returning it.
What I have:
List<Lead> testLeads = Test.loadData(lead.sObjectType, 'testLeads');
Assert.isNotNull(testLeads[0].Id);
What I need:
List<Lead> testLeads = Test.loadData(lead.sObjectType, 'testLeads');
Assert.isNull(testLeads[0].Id);
insert testLeads;
Assert.isNotNull(testLeads[0].Id);