O'Reilly logo

Mastering Application Development with Force.com by Kevin J. Poorman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Assertions

If you take nothing else away from this chapter, let it be this—tests without assertions are not tests, but liabilities. Without the assert calls, you cannot check the outcome of your executed code block to see if it functioned properly. That's why I refer to test methods without assert calls as liabilities. Inevitably, when the code fails for whatever reason, you're accountable for the consequences. At 3am. On a Saturday. It's even worse, if your code is mission critical and fails at the quarter's end! Practice safe testing, use asserts.

The Salesforce1 platform provides us with three basic assertion methods. The first method, System.Assert(expression), evaluates the expression within for a Boolean true or false. Thus, you can use it ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required