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
newbiewvfdevnewbiewvfdev 

How do you write testMethods for validation rules in visualforce

Hi there,

 

I have a visualforce page with a textBox and a save Button.  The textBox is an inputField and I have set it to required to true. How do I write testMethods to check if this works properly?

Ispita_NavatarIspita_Navatar
Test Methods are written to ensure that the data being created in them traverses each if-else conditions and loops in a given functionality, so that your code is covered. In case you have made the field required at the page layout or in Visual Force Page then in case if you try creating an instance of this record in the test method without providing value of the required field then the code in test-method will allow the creation of such data, but in case you made the field required at the schema level then simple creating of a an instance with and without the required field will test your functionality.