You need to sign in to do that
Don't have an account?
bodhi
visualforce unit test for selectoption
I have a fairly simple selectoption that I use on a VF page. How do I create a unit test for it:
public List<SelectOption> getLocationItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('On-Phone','On-Phone'));
options.add(new SelectOption('In-Person','In-Person'));
return options;
}
public List<SelectOption> getAE_LocationItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('On-Phone','On-Phone'));
options.add(new SelectOption('In-Person','In-Person'));
return options;
}public List<SelectOption> getAE_LocationItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('On-Phone','On-Phone')); options.add(new SelectOption('In-Person','In-Person')); return options; }
This will work for you, just put it inside a proper test class and specify the name of the class being tested unless this is inside the class with your production code. I.e. replace "getLocationItems()" with "[nameofclass].getLocationItems()".
Does that work?
Jeremy
All Answers
This will work for you, just put it inside a proper test class and specify the name of the class being tested unless this is inside the class with your production code. I.e. replace "getLocationItems()" with "[nameofclass].getLocationItems()".
Does that work?
Jeremy
I appreciate the prompt reply! That worked! I had already created a record as "a", so the final working result was:
list<SelectOption> testoptions = a.getLocationItems();
However, since no good deed goes unpunished ;), I'm going to throw one more part of the puzzle out to ask for assistance in creating the test class for:
public string get_Location() {
return Location;
}
public void set_Location(string Location) {
this.Location = Location;
}
Assuming that these are also methods on the record a:
Worked perfectly. Thanks!