0

I have test class that fails in production while executing it from the developer console, but when deploying other things it pass. Note, that it is not related to the user, same run/delpoyment is with the same user.

The test run code that create permission set, therefore it getting error of MIXED_DML_OPERATION. All the data that being created before the permission set are data for the test and it's before Test.StartTest(). I thougth using the StartTest() create new context, but appearntly not it's only resetting the limits.

Anywy, it working if I moved all the creation of data to @testsetup function.

But still trying to understand: why it is not failing during deployment?

  • 1
    You must share your code here if you want the community to analyze the problem. – Adrian Larson Feb 13 '17 at 7:04
  • 1
    If you have mixed dml you should wrap the relevant code in a system.runAs block – Eric Feb 13 '17 at 7:47
  • Thanks. Indeed using runAs solve this issue. Please write it as comment and I will be able to marked it as solved.... Still couldn't understand how come it's not failing during deployment. – Liron C Feb 13 '17 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.