You need to sign in to do that
Don't have an account?
Sri549
Unable to Run Test Class for Batch
Hey ,
I am unable to write perfect test class for Batch apex. I am getting an exception like " No More than one ExecuteBatch ca be called from within test method.Please make sure the Iterable returned from your start method matches the batch size, resulting in oe executebatch invocation".
Could some one help me in this situation.
Thanks!
Srinivas
I am unable to write perfect test class for Batch apex. I am getting an exception like " No More than one ExecuteBatch ca be called from within test method.Please make sure the Iterable returned from your start method matches the batch size, resulting in oe executebatch invocation".
Could some one help me in this situation.
Thanks!
Srinivas
Generally we see this error when processing more than 200 records in test class for Batch apex class
Resolution:
- Try to pass the less than 200 records in test class.
- Use Test.isRunningTest to bypass the code starting the second job in this context. Meaning that you will have to test your second batch job in a separate test to get coverage and assert behavior. In doing so you will obviously have to reproduce manually in the test code the state in the database the second job expects. Not ideal, but should work.
The following is an example of the change to avoid the second batch job being executed during test execution.Note
Please see https://help.salesforce.com/articleView?id=000330685&language=en_US&type=1&mode=1 (https://help.salesforce.com/articleView?id=000330685&language=en_US&type=1&mode=1)
Anudeep