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
chinnyychinnyy 

Help With Test Class for apex class please

Hi,

 Can any one help me out to write test class for below apex class.

 

public class StopRecursivecall
 {
                 private static boolean Update_OnBehalfendUserStatus = false;
      public static boolean hasUpdate_OnBehalfendUserStatus() 
                  {
        return Update_OnBehalfendUserStatus;
     }
                 public static void setUpdate_OnBehalfendUserStatus() {
        Update_OnBehalfendUserStatus = true;
    }
 }

 Thanks,

Indu.

Best Answer chosen by Admin (Salesforce Developers) 
Prafull G.Prafull G.
Hi Indu,

As yvk mentioned, its pretty straight forward to write test class for it.

Moreover, I think you are using this class to avoid recursive call of your triggers, therefore It should be covered when your actual scenario occurs.

If its not covered with triggers, You can instantiate the Apex Class and call the methods to cover it ion test method.

Cheers!

All Answers

yvk431yvk431

May I know your problem, it looked pretty straight forward. 

 

 

--yvk

Prafull G.Prafull G.
Hi Indu,

As yvk mentioned, its pretty straight forward to write test class for it.

Moreover, I think you are using this class to avoid recursive call of your triggers, therefore It should be covered when your actual scenario occurs.

If its not covered with triggers, You can instantiate the Apex Class and call the methods to cover it ion test method.

Cheers!
This was selected as the best answer
venkateshyadav1243venkateshyadav1243

hi

 tyr these


@istest
public class testStopRecursivecall
{
public static testMethod void myTest()
{
StopRecursivecall sr=new StopRecursivecall();
StopRecursivecall.setUpdate_OnBehalfendUserStatus();
StopRecursivecall.hasUpdate_OnBehalfendUserStatus();

}
}

yvk431yvk431

You donteven need to instantiate since they are static methods.

 

--yvk

chinnyychinnyy

Hi..Thanks for your reply.Your answer solved my problem & doubt.

 

Thanks & Regards,

Indu