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
vasu takasivasu takasi 

how to get a particular variable from a method for writting test method

hi i have code like

public class abc


string s1='picklist';

string s2;

string s3;

public void m1()




//some code here

else if(s1=='text')





in text method how to pass s1 value ?;


please help me.

Baktash H.Baktash H.

public void m1(String parameter){

if(s = 'picklist') System.Debug('Hello');



You have to call the function like this:



the string you pass will be the parameter the function gets.


public static testmoethod void testClass(){


  abd a = New abc();


  a.S1 = 'picklist';


   //Then test for results here


  a.S1 = 'text';


  //Test for results here




You instantiate the class, then set the variables, then execute your method as above