You need to sign in to do that
Don't have an account?
Saravanan @Creation
How to write test code for javascript remoting method in apex class
Hi All,
can any one please tell me how to write test code for java script remoting method in Apex class.And I am passing argument from page.
sample codes are appriciated.
yes just like below
String s='Base Product';
Class_Name.RemoteMethodName(s);
In the above code 's' is the parameter value that i need to pass to remote method.
All Answers
Just like any other class. The remoting just allows the JAVA to call it. It does not change (basically) how you initiate a test method for the class
Hello,
The previous reply is true but with a little twist given that you are testing goblal methods so the usual way of writting test methods for controllers is slightly different.
Basically to test a Remoting method, just call the method directly like so:
String param = 'test'; // lets pretend this is the parameter you need to pass into the method.
remotingMethod1(param); //this is the remoting method your calling.
If you return a value from the method then just create the proper variable and assign the results to it. Then do some asserts to verify its doing what it should.
BTW: YOU should be the one to mark as Solution the answers you feel were the ones that answered your issue, not us. So please check if this is solving your issue and mark it as solved so others can benefit from your experience.
yes just like below
String s='Base Product';
Class_Name.RemoteMethodName(s);
In the above code 's' is the parameter value that i need to pass to remote method.