+ Start a Discussion

created validation rule and apex test class failed

Hi, I am trying to deploying a simple component from sandbox to production, but got this error:



11Failure Message: "System.DmlException: Update failed. First exception on row 0 with id 00600000008dLSvAAM; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Validation Formula "existing_customer_VO_validation" Invalid (null): [StageName]", Failure Stack Trace: "Class.Test_OppMilestone.Test_OppMilestone: line 45, column 11 External...


I checked the class and it creates some dummy opportunity and the validation rule fired on the stagename.


Is there a way to prevent validation rule working on test classes?


PS: I am not a programmer and have very limited knowledge to apex coding. 




The error indicates the Stage field is null for the dummy opportunity in the test method.  Stage is a required field.  You need to add a line to your test method to populate the Stage field with a valid value.  Then the validation rule should pass.