Well rested and refreshed after lunch I wanted to dive into some code and check out some more of the developer sessions before watching Malcolm Gladwell in this afternoons keynote. Being a long time advocate of agile programming and test driven development I wanted to check out the Apex Testing Best Practices session.

As you may know, prior to promoting any application into production on the Force.com platform you are required to have at least 75% code coverage, but Taggart Matheisen, Director of Product Management for APEX did a great job of demonstrating why, even at 100% coverage, there are still a number of areas which developers should make sure they test.

Taggart used the example of validating bulk operations as a test which is often overlooked as many developers who focus soley on how information is entered via the User Interface but do not consider how the code may be used via API or bulk operations. In addition, he demonstrated how the new System.runAs(user) method introduced in Winter 09 can be a valuable tool for executing tests in the context of a particular user. Finally Taggart highlighted another new addition, the @isTest annotation, which when prefacing a testmethod, excludes that method from counting against the 1MB organizational limit for all APEX scripts impossed by the Governor.

For more APEX testing best practices be sure to check out the Testing and Code Coverage page on developer.force.com

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS