You need to sign in to do that
Don't have an account?
Advanced Apex Specialist - Step 4
I keep getting this on the 'Check Challenge' for Step 4 of the Adavanced Apex Specialist:
Ensure constructAccounts returns a list of size cnt of uniquely named Account records with all of the required fields populated.
This makes no sense to me as my method does create the correct number of Accounts and places them in a List? They are also uniquely named?
/**
* @name CreateAccounts
* @description Constructs a list of Account records for unit tests
**/
public static List<Account> ConstructAccounts(Integer cnt) {
// Ensure this method returns a list of size cnt of uniquely named Account records
// with all of the required fields populated.
List<Account> accounts = new List<Account>();
// Create the number of Accounts that was passed in
for (Integer i=0; i < cnt; i++ ) {
Account oAccount = new Account();
oAccount.Name = 'TestAccountLtd_' + cnt;
accounts.add(oAccount);
}
return accounts;
}
Any ideas why it is failing this?
Ensure constructAccounts returns a list of size cnt of uniquely named Account records with all of the required fields populated.
This makes no sense to me as my method does create the correct number of Accounts and places them in a List? They are also uniquely named?
/**
* @name CreateAccounts
* @description Constructs a list of Account records for unit tests
**/
public static List<Account> ConstructAccounts(Integer cnt) {
// Ensure this method returns a list of size cnt of uniquely named Account records
// with all of the required fields populated.
List<Account> accounts = new List<Account>();
// Create the number of Accounts that was passed in
for (Integer i=0; i < cnt; i++ ) {
Account oAccount = new Account();
oAccount.Name = 'TestAccountLtd_' + cnt;
accounts.add(oAccount);
}
return accounts;
}
Any ideas why it is failing this?
The Account name has the cnt variable being concatenated to the end and not the i variable, so all the Account names are the same. Doh!!