You need to sign in to do that
Don't have an account?
Testing scheduled batch job
Hi,
I am running a scheduled batch job where I perform the DML operation inside the finish method. I placed a debug log inside the finish method to print out my records to see if everything is updating the values correctly and it does, and from the test log I see that it performs the update as well.
Now the problem is, after I do my Start.Test() and Stop.Test() where I schedule my class to run and set up data, I query the objects I have updated and print them out nothing happens to them....
When I look at the execution in the test log, the print outs in my test method are occuring before my debugs in both my execute and finish methods.
Am I missing something here? It looks as if my assertions and debugs are occurring before the fact rather than after and I'm not quite sure how to fix it.
Any feedback would be appreciated.
Thanks
What is the issue coming? Is the test method not covering much or not?
Is your batch apex executing properly?
Thanks
I get 100% coverage. I can post the code if you want but for now here is my test class so I can explain a little better
Those last three debugs from the debug log seem like they are occurring before my execute and finish method even happen. Because I see the records that are suppose to be inserted have the correct values and I see that 1 row has been inserted. But I get the wrong values inside those print outs
I'll just post the code as well.
Scheduled Class:
Batch class
I need to pull all emails and count how many with text matching a quick text message have occurred in the last 30,7, and 1 days. So I need to use a batchable state that continuously updates the counts on the quick text object then update in the finish method.
But my debugs aren't matching up :/
After further investigation,
It appears the test method completes before the execute and finish method in the batch class even fire. Do I need to specifically call out the batch class in the test method even though it's called in the scheduled class? Both execute and finish methods but completely after the test method.