function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pallavi singhPallavi singh 

How to include the error info in the test class?

Hi 
i want to include this error info into my test class now my test class is covring 91% but i need 100% coverage.

for(Database.Error error : errors) {
                errorStrings = errorStrings + ' ' + error.getMessage();
            }
        }
        return errorStrings;
    }
Best Answer chosen by Pallavi singh
PriyaPriya (Salesforce Developers) 

Hey Shruthi,

In the test class, You have to create a condition that causes the error, such as leaving a required field (name, for example) blank.

Kindly mark it as the best asnwer if it works for you.

Also refer this where similar discussion has done :- 
https://developer.salesforce.com/forums/?id=906F0000000kEbrIAE

Thanks & Regards,

Priya Ranjan