function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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 =;


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.