You need to sign in to do that
Don't have an account?
Samuel Wolfe
How to insert both a user and an account before Test.startTest() (mixed DML)
So I am confused. I need to be able to insert a new User with a specific profile/permission sets and a new account before starting my Test.startTest block.
If I create the User first, then creating the account causes
How do you accomplish this?
If I create the User first, then creating the account causes
MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa)The documentation recommends using @future methods, but this won't work because I need the guarantee that both the account and user exist before running my test.
How do you accomplish this?
Then you use System.runAs(Admin) to create the account, and System.runAs(userToTest) to actually perform the test.