function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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
}