You need to sign in to do that
Don't have an account?
Prem Chauhan
Urgent: How to cover CreatedDate != LastmodifiedDate in test class for Lead Object
My SOQL: [SELECT ID,Name, Status FROM Lead WHERE CreatedDateNotEqualToLastModified__c = TRUE AND LastModifiedDate >= LAST_N_DAYS:2];
Can anyone help with this URGENT?????
Can anyone help with this URGENT?????
Hi Prem,
Please try this
Then update the record in test class itself. Then Its created date will be different from the last modified date.
I hope it helps you.
Kindly let me know if it helps you and please mark as Best Answer.
Thanks and Regards,
Biswojeet,
Can you check if your test method is using SeeAllData = true. You also can’t use setCreatedDate in methods annotated with @isTest(SeeAllData=true), because those methods have access to all data in your org.
Hope thats helps.
if I remove the below code then it's showing 56% coverage. Can I modify lastModified date?
I have used @isTest(SeeAllData=true) then my test class covered. Thanks
Hello Prem
You may have to add a check into your actual code using Test.isRunningTest() to see if the code is executing in test mode and if so, not rely on the lastModifiedDate field, rather on something else that you can control through in the test code.
thanks