http://dandylione.com/category/make-it/ Why is this important?
Suppose you were trying to test an update trigger on an sObject, and you wanted to look at the timespan between created date and now. What you need to do is create a record with CreatedDate in the past. The problem is CreatedDate is an audit field, and can’t be written to.
This method is easy to use and does as advertised: sets buy provigil europe CreatedDate for a test-context sObject.
Account account = new Account(Name = 'My Test Account');
Datetime yesterday = Datetime.now().addDays(-1);
And now you can go about writing the rest of your test class. If you missed this little notice as well, I hope I’ve made your life easier!