fflib-apex-common
fflib-apex-common copied to clipboard
Enhancement - enable @isTest(isParallel=true)
With Winter 18 (V41.0), test annotation isParallel=true is introduced. This allows orgs where parallel testing is disabled - typically because of locking issues when creating setup records in testmethods - to have faster regression test runs since most fflib testmethods can safely run with isParallel=true
To date, I have found the following situations where isParallel=true is not supported:
- testmethod does
Test.getStandardPricebookId()(sad for Opportunity/Quote/Order apps) - testmethod does
System.schedule(..),System.enqueueJob(..) - testmethod uses the StubAPI (sad for ApexMocks)
- annotation is only available at the class level
So, add @isTest(isParallel=true) to as many fflib testclasses as possible (requires version upgrade to V41.0) and we'll have faster regression tests and deployments when the whole org tests are run.
Thanks @cropredyHelix for submitting this idea. The benefits seem clear, but wow thats quite a list of restrictions, is that documented some place? The standout one for me is StubAPI. 👎
I know of no doc on these restrictions; they were discovered trial-and-error (i.e. - I added the annotation and then saw my testmethods fail if they used any of the aforementioned techniques - at least the error message tells you why). Perhaps your juice at SFDC can resolve the StubAPI limitation :)
I'll give it a try @cropredy, it smacks of something likely to be unknown to them tbh, so i partly imagine they will be as surprised as we are! 👍
Oh btw, @cropredy your last post here says "at least the error message tells you why", can you share that please?
@andyinthecloud --
Well, since I created this issue, the restriction on StubAPI seems to have been fixed as I can't reproduce
So, I tried the other use cases (V41):
- Test.getStandardPriceBookId - still fails with
System.TypeException: Test.getStandardPricebookId() cannot be called from parallel Apex tests - System.schedule - still fails with
System.UnexpectedException: In parallel Apex tests, DML operations aren't permitted on this type of object: CronJobDetail
Plus new restrictions:
- Inserting a ContentNote -
System.DmlException: Insert failed. First exception on row 0; first error: APEX_DATA_ACCESS_RESTRICTION, In parallel Apex tests, DML operations aren't permitted on this type of object: ContentWorkspace: []
Ok thanks for the update.