Created
September 23, 2014 20:24
-
-
Save mickle00/70179703e885292793a0 to your computer and use it in GitHub Desktop.
Showing that the Apex Flex Queue does not appear to work in the context of Unit Tests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class FlexQueueExample implements Database.Batchable<sObject>{ | |
global Iterable<sObject> start(Database.BatchableContext BC) { | |
return new List<sObject> {}; | |
} | |
global void execute(Database.BatchableContext BC, List<sObject> scope){} | |
global void finish(Database.BatchableContext BC){} | |
// Works in Execute Anonymous for Count <= 100 | |
global static void run(Integer count){ | |
for (integer i=0; i<count; i++){ | |
database.executeBatch(new FlexQueueExample()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest (seeAllData = false) | |
private class FlexQueueExampleTest { | |
//System.LimitException: Attempted to schedule too many concurrent batch jobs in this org (limit is 5). | |
private static testMethod void shouldBeAbleToUseFlexQueueInTests(){ | |
FlexQueueExample.run(10); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment