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
hiteshwar marnihiteshwar marni 

how to bypass validation and workflow rules while writing test classes

Chandra Sekhar CH N VChandra Sekhar CH N V
Create a Custom Setting of type Hierarchy with a checkbox in it that disables validation rules for a given user or profile and then add this condition in your validation rule.

Check if below posts will guide you - 

https://learnsf.wordpress.com/2011/05/21/disable-validation-rules-4-data-load/
http://bobbuzzard.blogspot.in/2011/11/bypass-validation-rules-from-apex.html
Arun Deepan LJArun Deepan LJ
The easiest way is to have a test setup class that covers all the validation  or you can manually disable the required validation before starting the test and make it active, after the testing is finished
Amol Bhalerao 7Amol Bhalerao 7
Check the solution in details here. implemented using hierarchical custom setting.
http://theapexhub.com/bypass-validation-rules-while-running-apex-test-class/