Answer: By default test class runs in System Mode. If you want to execute a piece of code in a certain user context then we can use system.runAs (UserInstance). For more details refer 2nd question in visualforce category.
To avoid MIXED-DML-OPERATION error we can include DML statements inside of system.runAs(), still the error persists keep DML statements inside of Test.startTest() and Test.stopTest().
Not sure what course is right for you?
Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.