When processing more than 200 records in a test class for a Batch Apex class, you may see the following error: System.UnexpectedException: No more than one executeBatch can be called from within a testMethod.
This error occurs because Salesforce limits test execution contexts to a single Database.executeBatch() call.
This error occurs when a test class calls Database.executeBatch() more than once during a single test execution. Salesforce limits test contexts to a single executeBatch call. To resolve this, either limit the number of records passed to under 200, or use Test.isRunningTest() to conditionally skip chained batch job execution during test context.
The following options are available:
The following example shows how to prevent a second batch job from being triggered during test execution by wrapping the Database.executeBatch call in a Test.isRunningTest() check:
public void finish(Database.BatchableContext)
{
if(!Test.isRunningTest)
Database.executeBatch(new MySecondBatchJob));
}
Notes:Test.isRunningTest — Apex Test Methods Reference
000386014

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.