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

Test class for update lead scenario

Hi, I am new to Apex.  I am having difficulty writing a test class for update lead scenario. 
I have written the code for new leads. Here, I am creating new lead records and inserting them, I am not sure of the approach to reference these newly created leads for update scenario. I also have to compare old and new values in update scenario.

Example : I created a lead ' test'  with  phone number = '12345', I inserted this record. Now,  I will update lead 'test' with phone number ='54321'.  Now, I want to compare old phone number and new phone number and perform next step ( insert into another object) only if 'phone number' value is changed for lead 'test'. How do I implement a test class for this scenario? Please assist. Thanks
Hello There,

If you can post your trigger/class code you have written to insert lead records, it would be easy to provide you some help in writing test class.