You need to sign in to do that
Don't have an account?
AvLav
Problems with get set testing.
Hy everybody!
I have some problem with the {get; set} formulas. Here is an example:
/* CODE IN MYCONTROLLER CLASS*/
String exampleString {get;set}
...
So, If I want to use the set method with a parameter, for example:
/* CODE IN MYCONTROLLERTESTMETHOD */
mycontroller controller = new mycontroller();
controller.setExampleString('TestString');
I got an error.
What does it mean exatly: {get;set}?
This syntax is used for automatic properties.
To test the setter, you simply assign a value:
controller.exampleString='MyExample';
To test the setter, you simply read it:
String str2=controller.exampleString;
There's more detail in the Apex Developer's Guide on page 97.
All Answers
This syntax is used for automatic properties.
To test the setter, you simply assign a value:
controller.exampleString='MyExample';
To test the setter, you simply read it:
String str2=controller.exampleString;
There's more detail in the Apex Developer's Guide on page 97.
Thanks your answer, you're right.
It's very simple (as you write: controller.exampleString=''MyExample') if you use the public access modifier. But my variable is private.
So I will change the modifier.