Skip to main content
5 events
when toggle format what by license comment
Aug 7, 2019 at 12:49 comment added Sainath exactly @PhilW, did same thing, created a list and added all the leads into list then inserted list using single insert.
Aug 7, 2019 at 12:21 comment added Phil W Note that inserts inside loops are a bad thing - you are limited on the number of DML operations you can perform in a given test execution. Better to create all the required instances using a loop then do a single insert of the list of instances. This is what is meant by "bulkifying".
Aug 7, 2019 at 11:55 comment added Sainath @PhilW, I did all the changes to the unit test code that you mentioned, then inside start test loop I inserted my leads, previous I inserted outside loop, when I inserted inside loop then it saved without issues and got 100% code coverage, thanks a lot for guiding me.
Aug 7, 2019 at 10:40 comment added Phil W Good to hear. Note that you should consider bulkifying the inserts and updates in your unit tests. I'd also question why you have try/catch blocks in the test that do something other than verify that the code does or does not throw an exception in the appropriate conditions. Also, this isn't really a unit test as it doesn't actually perform any asserts to verify that the logic has correctly updated object state. Finally, you should avoid use of the deprecated testMethod keyword and use the (at)IsTest annotation instead.
Aug 7, 2019 at 10:37 history answered Sainath CC BY-SA 4.0