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
kirankumarreddy punurukirankumarreddy punuru 

how to bypass validation rules in apex test class

Hi,
    Iam having some validation rules on some  field let us say that field is discount in the apex class iam having the condition like
 
if(obj.discount >100)
{
 some code
}
   
now to cover this condition in the test class it is not allowing and showing an exception like this
; first error: FIELD_INTEGRITY_EXCEPTION, The Discount Percent must be between 0 and 100: [Discount]
how to overcome this exception any ideas
ManojjenaManojjena
Hi ,
You can add one condition in teh validation rule that it should not fire for admin profile or you want for system admin as well ?