function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nikhil Sharma 17Nikhil Sharma 17 

MIXED_DML_OPERATION, Error in TestClass

MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Account, original object: EmailTemplate: []
Best Answer chosen by Nikhil Sharma 17
sumit singh 37sumit singh 37
2) When doing 'setup-object DML' in your test methods, such as creating test Users or Groups, wrap the DML statements as follows:

User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ];
System.runAs ( thisUser ) {
    ...your setup-object DML...
}