You need to sign in to do that
Don't have an account?
Swapna Prasade
in apex test how to assert if a method in apex class is getting called and how many times
In Apex Test , i need to verify that specific method of the Apex class that i am testing, is getting called when i run the test. I am looking for something similar to .toHaveBeenCalledTimes () that is available in javascript.
Appreciate any help on this!
Appreciate any help on this!
There is no method that tells you a method runs how many times. You can create a global static variable and every time when the method runs in that method increment the variable and at last, in the test class, you will get the count in the variable.
Please mark this as the best answer if it helps.
Thanks
Shubham Jain
All Answers
There is no method that tells you a method runs how many times. You can create a global static variable and every time when the method runs in that method increment the variable and at last, in the test class, you will get the count in the variable.
Please mark this as the best answer if it helps.
Thanks
Shubham Jain
If it works for you, please mark it as the best answer, it would really help.
Thanks
Shubham Jain
Yes, you can. Declare a variable public static Integer counter = 0; in the apex class.
Thanks
Shubham Jain