You need to sign in to do that
Don't have an account?
Alex Sidlinskiy
Invalid type: Database.InsertResults
I'm writting a unit test on apex snippet that restricts contact by name or last name to be specific. I'm getting error "Invalid type: database.InsertResults" on line 18. Thanks in advance.
@isTest public class TestRestrictContactByName { @isTest static void TestInvalidName() { // Test data setup // Create empty list for contacts List<Contact> contacts = new List<Contact>{}; //Iterate over each contact for(Integer i=0; i<200; i++){ Contact ct = new Contact(LastName='INVALIDNAME' + i); contacts.add(ct); } // Perform test Test.startTest(); insert contacts; Database.InsertResults result = Database.insert(contacts, false); Test.stopTest(); System.assert(!result.isSuccess()); System.assert(result.getErrors().size() == 200); System.assertEquals('The Last Name "'+contacts.LastName+'" is not allowed for DML', result.getErrors()[0].getMessage()); } }
All Answers
And I'm getting error on line 23 "Initial term of field expression must be a concrete SObject: List".