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
SurekaSureka 

Code coverage for History class

Hi All,

 

I have written an apex class to display history related list of Lead record. I am using the following code to cover the test method:
             

LeadHistory leadHist1 = new LeadHistory(LeadId =lead.Id,Field='Created');
insert leadHist1;
LeadHistory leadHist2 = new LeadHistory(LeadId = lead.Id,Field='status');
insert leadHist2;   

 

 But, I am not able to cover few lines ie. value change in the lead object(oldValue & newValue). Because, oldValue & newValue fields of History object are not writable. Please let me know, if you have any idea on this.

 

Thanks

Bhuvana

Shashikant SharmaShashikant Sharma

History records are not available in Test Context, so you can not cover such code where you SOQL history records and use it further.