Executing your code

After creating test data and calling test.startTest(), we are now left with executing our code. This is where our general testing pattern branches into three subpatterns. Each of these subpatterns does execute the code, but each in their own unique and important way. Of the three, the first subpattern is the easiest to understand and what you're most likely to have run across. I call this types of tests Positive tests because they're based in the positive assumption that your code is working as intended with valid data. The second subpattern is less intuitive, but far more powerful. I call these Negative tests because they test what happens when exceptions occur. Lastly, there are Permissions tests that test how your code functions ...

Get Mastering Application Development with Force.com now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.