Tag Archives: unit testing

Apex Template: Visualforce Controller

Last week, we took a look at a skeletal version of a class implementing the asynchronous aspects of Apex: batch, scheduled and email. While powerful, it’s a corner of Apex developers don’t always have a use case to tread down into. This week, let’s look at something a lot more common: Visualforce controllers – quite possibly the most common use of Apex on the planet. Continue reading

Unit Test Scoping in Spring ’12

There are several pitfalls that developers can fall into when writing unit tests, and traditionally speaking one of the easiest to fall into can be coding with a reliance on existing data.  So for instance, you want to to prove that your SOQL is correctly getting data from your custom object – this unit test might seem relatively innocent:
List<Furniture__c> dressers = [SELECT ID, Name, Type__c from Furniture__c where Type__c =: dresserFilter LIMIT 10];

Which works great in the sandbox where you’ve been developing your custom furniture application with test data, but might instantly break when you move… Continue reading