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

Calling setter from test method
When using the get; set; type syntax for a method in my controller:
public Id AccSel {
get;
set {
AccSel = value;
selectedAcc = accMap.get(AccSel);
}
}
How do I call the method directly from my unit test (to get code coverage)? The documentation examples all use the other syntax where you have methods like getAccSel and setAccSel, which you can of course call from the test method. In order to cover this code, do I have to rewrite it with separate getAccSel and SetAccSel methods instead of using automatic properties?
If it is possible, how do I pass the parameter of "value"?
From the VF page I call it using assignTo:
<apex:commandButton value="Refresh List" action="{!resetConts}" rerender="ContactLst, ContDetailpg">
<apex:param name="AccSel" value="{!selectedAcc.Id}" assignTo="{!AccSel}"/>
</apex:commandButton>
Using
ApexPages.currentPage().getParameters().put('AccSel', ids);
does not call the setter.
Any ideas?
Thanks
When using "automatic" properties, simply setting the value on the object should exercise this.
E.g.
myController.AccSel=myId;
All Answers
When using "automatic" properties, simply setting the value on the object should exercise this.
E.g.
myController.AccSel=myId;
Thanks, Bob. Works a treat of course. I should have worked that one out. Sometimes we make things more complicated than they are!
Regards,
Erica