I have an apex test code, That passes in the sandbox and gives an 89% code coverage for a specific code, And the code and the test code are validated and deployed in production, Without problems, And the APEX code works in fine in production,

But when I try to run the test code in production it fails,

How is this possible?

I would like to add that the test code uses :seealldata=false, And i looked at the APEX debug log file for my account after execution of the test, The log file does not show any errors, It just shows the step by step execution, Which seems all fine,

  • 3
    What is the failure? Whats the error message? There are a few reason this could happen. A lot of time this happened because of a validation rule in production that wasn't present in the sandbox org. – Chris Duncombe Nov 14 '13 at 1:01
  • 2
    Another common reason for this type of problems is a test that is using real data, can you verify that your test is creating its own data? – PepeFloyd Nov 14 '13 at 3:00
  • Your problem should only raise concern if your Sandbox is a facsimile (exactly the same) except for only your Class + TestCode at hand. Did you add a field, RecordType, Validation Rule, object, class, ... that you added in Sandbox but you forgot to add to Production? – Scott Pelak Nov 14 '13 at 5:46
  • or could it be that you have not brought in your test class into production? – Bart Nov 14 '13 at 12:46
  • let me check all the objects i updated in the sandbox, To see if they were all deployed, – user2333346 Nov 14 '13 at 15:18

There are many reasons why tests fail after deployment to production. This can include additions or changes to validation rules, dependency on unique ID values that represent records that were later deleted, changes to a field's requiredness or uniqueness attributes, and other similar changes. In summation, you would have to actually read the debug logs from the tests to determine what change may have caused the failures.

| improve this answer | |
  • I would add also if the unit test data was not isolated and could view production data. – greenstork Nov 14 '13 at 14:15

Ok, someone gave me the solution on another form, and it worked:

Develop --> Apex Text Execution and

After clicking Options..., I checked Disabled Parallel Apex Testing And then clicked the link "View Test History" where I clicked Clear Test Results. Then I went to Develop --> Apex Classes and

Clicked "Compile all classes" Then clicked "Estimate your organization's code coverage" And finally, I clicked Run All Tests After all that, I am now able to execute Apex tests again.

Source: "Could not run tests on class ..."

There is also a form that people are signing up for,


| improve this answer | |
  • I just would like to add based on my experience, check out some on Validation Rules .Just now I face the same issue and actually it turn out my class contain negative case for Validation Rule.This validation rule I created in Sandbox to simulate fail scenario and completely forget about it during deployment.I really hope that in future we can see what code coverage during Deployment Validation. – unidha Dec 21 '16 at 6:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.