+ Start a Discussion
etechcareersetechcareers 

how do you call string methods in testunits?

hi :

   I love testunits :)

How do you call the following in a test unit:

 

  public String rtps {get{return rtps;} set{ rtps = value;}}

 

Thank you

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You "call" automatic properties simply by accessing them.

 

Assuming the class that contains the rtps property is called MyClass, you'd have something like:

 

 

public static testMethod void testRtps()
{
   MyClass cls=new MyClass();
   cls.rtps='Test';   // tests the setter
   System.assertEquals('Test', cls.rtps);  // tests the getter
}