You need to sign in to do that
Don't have an account?
Test method coverage problem: No more than one executeBatch can be called from within a testmethod
I have written a test method for batch apex. i am facing issue like '"No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation."'
Test.startTest();
PageSubsNotification job = new PageSubsNotification();
job.mysoql = 'SELECT ContentDocumentId, Title FROM ContentVersion where Portal_Segmentation__c =\'Registered Visitor\' limit 1';
ID batchprocessid = Database.executeBatch(job);
Test.stopTest();
can anybody give me a solution for this. pls
That error states that, you can only execute a batch class once from a test class. It might be the case that, your org contains more than 200 records or you have mimimised the number of records to the batches.
The best solution so far is to limit the query batch class for a test method.
You need to add the highlighted code in the start method(Or in constructor), Just to add the limit clause for limiting number of records passed to batch class.
Hope it helps.