All Ideas

Idea Details

Post an Idea
This idea has been delivered and can no longer be voted or commented on. If you’d like to add to this conversation, please post a new idea.
1,120  Points voting closed
Delivered in Spring 16
Idea is generally available.

Allow the setting and/or modification of the CreatedDate field in unit tests.

Salesforce Platform, Apex & Visualforce

It is extremely frustrating when I am writing unit tests to test code that performs comparisons of the Created Date (CreatedDate) field or filters off of the CreatedDate field. In my Apex unit test, I cannot create test records and then set or modify the CreatedDate field of those records to test my actual code. To go around this problem I have to devise and formulate extremely ugly workarounds to test my code using unit tests. It would be ideal to allow modification of the CreatedDate field atleast in the context of Apex Unit Tests.

· Flag

Latest Comment from Salesforce

  • Jennifer Sacks - 3 years ago

    This is delivered with the Spring '16 release. For full details, please see the release notes: http://releasenotes.docs.salesforce.com/en-us/spring16/release-notes/rn_apex_tests.htm#rn_apex_tests_setcreateddate
  • Upvotes
  • Downvotes

Ideas

Apps

from AppExchange

Questions

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



 

 

Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


 

Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.