+ Start a Discussion
David Roberts 4David Roberts 4 

different apex:input value during testing of a visualforce page

I'm currently hardcoding an input value into a vf page.
When testing, I want a different value.

<!-- Normal Run-->
<apex:input value="runtime" name="status"/>
<!-- Test-->
<apex:input value="testing" name="status"/>

Does a vf page have the equivalent of the apex isTest() function?

or is there another method of forcing a different value to be used during testing?
Raj VakatiRaj Vakati
Vf don't have any function like isTest .. Use Custom setting or  Custom label or metadata to change the value based on your  need 
  • Create a custom label and add the value over there 
  • Call the custom label in the input tag value 

To access custom labels, from Setup, enter Custom Labels in the Quick Find box, then select Custom Labels.
How you add a custom label to your application depends on the user interface.
In Apex use the System.Label.Label_name syntax.
In Visualforce and Lightning components, use the $Label global variable.
<apex:input value="{$Label.MY_CUS_LABEL}" name="status"/>