I have a batch class that I want to test (with a test method) on a high data volume, higher than 200. I get a "Too many SOQL queries: 201", on a line which calls Messaging.renderStoredEmailTemplate() which is made several time for 1 record process.
So I'd like to limit the number of SOQL queries in 12 transaction.
In the documentation I see the optional 'scope' parameter of the database.executeBatch() method to limit data processing.
It looks like it doesn't work like explained:
- If I use 200 or 199, I fall into the "Too many SOQL queries: 201" error -
- If I use a lower value for scope like 100 or 150 and even 1, I get the following error:
No more than one executeBatch can be called from within a test method. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.
making believe that it tries but can't recall the execute() method of my batch. This message also makes think that the scope parameter has no influence on the batch size.
How does this parameter 'scope' work? How can I get control on the Batch size ? Is it possible to perform Tests with Test methods on high data volume (> 200 records)?
Thank you for your help
execute
method once so you gave ti setup the number of records accordingly.