Increase code coverage and quality by writing better Apex unit tests for external objects and mock SOQL query responses using the new SOQL stub methods and a new test class. Use basic and joined SOQL queries against external objects and return mock records in a testing context. Apex governor limits apply to the stubbed records
How: Create mock test classes by extending the new System.SoqlStubProvider class and overriding the handleSoqlQuery() class method. Create external object records using either Test.createStubQueryRow() or Test.createStubQueryRows(). Register the mock provider in the test using Test.createSoqlStub() and execute the test code
The SOQL query must be against an external object, either directly with a FROM clause or via a subquery. These features aren’t allowed within a stub implementation
- SOQL
- SOSL
- Callouts
- Future methods
- Queueable jobs
- Batch jobs
- DML
- Platform events