Test passes on Validation and fails on Deployment

I’m trying to deploy a change set with one updated class to production.
When I run Deploy it fails because an assertion failure in some other class in my org.
When I run Validation only it passes with no errors and when I run all tests in my production org I get no errors as well.

Any idea why I get the failure only on deployment?

Answer

It’s probably because when the failing test class was written it was done using the properties of the person that wrote it (probably something off his user record or something he has access to and you don’t). Now that you’re deploying your code, that class is being tested as you, and you didn’t match his test class for whatever reason.

If this is the case, change that test class to use the RunAs method. Here is some documentation that should help.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_tools_runas.htm

Attribution
Source : Link , Question Author : Dedo , Answer Author : PartOfTheOhana

Leave a Comment