+ Start a Discussion
Eli Flores, SFDC DevEli Flores, SFDC Dev 

setting the close date on case in test method

I need to set my unit tests for specific ranges for closed cases but in my test method when i try to 


Case cs =new case();


cs.closedDate = datetime.now().addDays(-15);


It throws an error saying that closedate is not writeable. How can I set the closedate in my test classes?


I think if you set the 'status' field to 'closed', you will get a date.