You need to sign in to do that
Don't have an account?

How to get test coverage for Database.Error?
Hey folks,
how can I accomplish a testcoverage for the Database.Error class?
This is my code:
Database.Saveresult[] lsr = Database.update(lstSchedulingsToUpdate, false); for(Database.SaveResult sr : lsr) { if(!sr.isSuccess()) { for(Database.Error err : sr.getErrors()) errorMsgs += sr.getId() + ': ' + err.getMessage() + '(' + err.getStatusCode() + ')' + '\n'; } }
Thanks in advance!
Josh
You have to create a condition that causes the error, such as leaving a required field (name, for example) blank.
All Answers
You have to create a condition that causes the error, such as leaving a required field (name, for example) blank.
For example - while creating a account you assign sales_Terrorory= sa.id . Later in the code just use delete sa; and you will see that Database.error triggered . -with errolist- entity is deleted