Timeline for How to cover a catch statement in a test class?
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 31, 2020 at 2:51 | comment | added | sfdcfox♦ | See also this question about 100% coverage. | |
Dec 31, 2020 at 1:44 | vote | accept | Krishnamurthy | ||
Dec 31, 2020 at 1:38 | answer | added | cropredy | timeline score: 4 | |
Dec 31, 2020 at 1:35 | comment | added | Kris Goncalves |
what's the point of that catch statement? Database.insert returns a Database.SaveResult[] that would contain success or error messages for each record attempted to be inserted. Doc. See also existing answers about blindly catching general exceptions. Typically, you'd catch an exception with a purpose/scenario in mind which makes testing it easier.
|
|
Dec 31, 2020 at 1:14 | history | asked | Krishnamurthy | CC BY-SA 4.0 |