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];
System.assertNotEquals(dressers.size(),0);
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








