Posts

Using try, catch and finally in test class (dreamhouseapp)

Image
up vote 5 down vote favorite In the test classes of the DreamHouse Sample app all the functions have the following structure: static testMethod void testSomething() { Boolean success = true; try { ... } catch (Exception e) { success = false; } finally { System.assert(success); } } Source: https://github.com/dreamhouseapp/dreamhouse-sfdx/blob/master/force-app/main/default/classes/PropertyControllerTest.cls What is the reason for or advantage of this structure? I am asking, since this app is kind of Salesforce-official (if I got that right) and it says "Get inspired and learn best practices." , so I thought there must be a reason... Thank you! unit-test try-catch ...