You need to sign in to do that
Don't have an account?
Kourt Neyra
How to write a test class for a scheduled apex class
Hi, I have an apex scheduled class and i want to deploy it to production, but it has a 0% code coverage, how can i write a test class for it? This is the code:
global class BorrarAsegurados implements Schedulable{ global void execute(schedulablecontext SC){ List<Enrollee__c> Asegurados = [select id from Enrollee__c where Policy_End_Date__c <= Yesterday ]; if(!Asegurados.isEmpty()) delete Asegurados; } }
Let us know if it helps
All Answers
Let us know if it helps
The only thing Ihad to change was in line 10, where I had to erase the "Public static" modifiers to the string variable. But now the code coverage is 100% , thanks!
I am analysing this test code and what I understand is that I need to write a code that verifies if the class is working properly, right?
In this case, I needed to create an enrollee__c record that was going to be erased with my class and then I needed to run the class, and for last I needed to check that the record was erased.
thanks!