About this question
I'm having issues with creating a pretty simple test Utility Class. I want to create two records: an account and a related child contact. The error I see in the developer console is:
Variable does not exist: a.ID
My code, based on the Salesforce Apex Workbook, is as follows. I've played around with various things, but it's not working. Where am I going wrong? Thanks in advance.
@isTest
public class AccountSaveTestSuite {
public static Account createOneAccount(){
Account testAccount = createAcct('ABC Computing inc.');
Contact testContact = createContact();
return testAccount;
}
// Helper methods //
//
private static Account createAcct(string accountName) {
Account a = new Account(
Name=accountName);
insert a;
return a;
}
private static Contact createContact(){
Contact c = new Contact (
FirstName = 'Jane'
, LastName = 'Smith'
, Account = a.ID); // *** Error is here ***
insert c;
return c;
}
}