Future methods run with the synchronous limits during tests
Last updated 2022-02-10 ·Reference W-3691104 ·Reported By 9 users
Summary
Apex Limits of apex future methods get set to the values of the synchronous limits when they are called between Test.startTest() and Test.stopTests().
Repro
1. Create a apex class
@isTest private class FutureTest {
@future private static void SOQLLimits() {
System.debug('SOQL Limit: ' + Limits.getLimitQueries());
}
@isTest static void testNothing() {
Test.startTest();
SOQLLimits();
Test.stopTest();
SOQLLimits();
}
}
2) Run the test
3) You can check the debug logs and see the SOQl limit is 100 within the test.starttest() method and it is 200 after test.stopTest()
Workaround
Call future methods outside a block enclosed with startTest() and stopTest(),
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.