Tag: Testing

Frameworks for testing Apex Code

I would like to share a couple of framworks that are very useful for testing Apex Code. The first one is Apex MockĀ and it will become essential for you when it comes to create test data for your Apex Test classes. The second framework isĀ FinancialForce ApexMocks Framework. This one allows you to decouple complex logic […]

CreatedDate in test classes

Finally Salesforce fills the gap and allows you to specify the createddate field within test classes. You only have to use the Test.setCreatedDate method introduced with Spring ’16. @isTest private class CreatedDateTest { static testMethod void test() { Contact c = new Contact(FirstName =’Marc’, LastName = ‘Benioff’); insert c; Test.setCreatedDate(c.Id, DateTime.newInstance(2016, 1, 26)); Test.startTest(); Contact […]