May 2019
Intermediate to advanced
546 pages
12h 41m
English
When you need to create setup objects (such as a user, territory, or permission set), you can't create any other regular object in the same unit test. If you do, you will receive an exception: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa). This means that you mixed up the creation of a setup object with a non-setup object (such as an account, contact, or custom object).
You can avoid this exception by creating your setup object asynchronously. In the following example, we will create the user asynchronously and the account in a separate method:
@IsTestprivate with sharing class MyTestClass { @future private static ...Read now
Unlock full access