You need to sign in to do that
Don't have an account?

How do I get test coverage on my radio button option?
I have a VF page with 5 radio buttons on. For the answer I use a radio button (see page item below).
My question is how do I test this because when I run my test class it doesn't touch this part of the the controllers List<SelectOption> part of the code?
Page item :
<apex:selectradio value="{!question1}" >
<apex:selectOptions value="{!QuestionItem}" />
</apex:selectRadio>
Controller item :
// Question radio buttons
public List<SelectOption> getQuestionItem() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('0','0'));
options.add(new SelectOption('1','1'));
options.add(new SelectOption('2','2'));
return options;
}
Test Class :
// Test 1
MyController controller1 = new MyController();
controller1.question1 = 1;
controller1.save();
Any help is appretiated. If I need to add more info just let me know as this is not all of the code just the bits I thought relevant.
Hi,
Test coverage for you question,
MyController cls = new MyController();
List<SelectOption> selOpts=cls.getQuestionItem();
where MyController is your class name...
If this post was helpful to you please mark this as a solution and give kudos....
Thanks and Regards,
Arunkumar.R | Salesforce Certified Force.com Developer.
All Answers
Hi,
Test coverage for you question,
MyController cls = new MyController();
List<SelectOption> selOpts=cls.getQuestionItem();
where MyController is your class name...
If this post was helpful to you please mark this as a solution and give kudos....
Thanks and Regards,
Arunkumar.R | Salesforce Certified Force.com Developer.
Great.
Thanks very much this worked straight away. Much appreciated.