Check partial DML results
Database.insert(rows, false) returns one SaveResult per row.
Your task
Finish the insert helper and a verifier that fails unless row 1 saved and row 2 failed because Name is missing.
@IsTest
public class AS_A3060F564EF1_SaveResultTests {
public static List<Database.SaveResult> insertMixed(String token) {
List<Account> records = new List<Account>{
new Account(Name = 'AS Valid ' + token),
new Account()
};
return new List<Database.SaveResult>();
}
public static Boolean verifyMixed(List<Database.SaveResult> results) {
return false;
}
@IsTest
static void mixedInsert() {
Assert.isTrue(verifyMixed(insertMixed('visible')));
}
}Requirements
- keepsValidRecord should pass
- reportsRequiredField should pass
- verifiesRealOutcome should pass
- catchesSecondRowSaved should pass
- catchesWrongErrorCode should pass