Hey i write extension for my custom controller. how to write test class for this extension, in this this extension im using just one javascript remoting method? here is my Extension Code
global with sharing class CheckExtension {
public CheckExtension(CustomCheck controller) { }
@RemoteAction
global static string getRecNumber(String Rec){
if(Rec==1)
return 'you Receive one Record ';
else
return 'you Receive Multiple Records';
}
}
Attribution to: Faisal
Possible Suggestion/Solution #1
Just call the method as you would a regular, static method. Your test method(s) might look like:
@isTest
private class MyTest{
static testmethod testRec1(){
Test.startTest();
String str = CheckExtension.getRecNumber('1');
Test.stopTest();
System.assertEquals('you receive one Record';
}
static testmethod testRecNot1(){
Test.startTest();
String str = CheckExtension.getRecNumber('2');
Test.stopTest(0;
System.assertEquals('you receive multiple records');
}
}
Attribution to: James Loghry
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33848