You need to sign in to do that
Don't have an account?
Problem in creating Test method for the web service class.
Hi all,
Here i am using the web service class which is to be used further by the flex page. The problem i am facing is how to generate the test method for the particular web service class and its codes are given below.
So, help me out to solve this problem and how to create the test method for the following web service class and what will be the test methods for this class.
CODE OF THE WEB SERVICE CLASS.
global class Questions{
webService static List<QuestionType__c> getQuestionType(Id id)
{
List<QuestionType__c> qType = [select id, name, Name__c, Summary__c from QuestionType__c where id = :(id) ];
return qType;
}
webService static List<QuestionType__c> getAllQuestionType()
{
List<QuestionType__c> qType = [select id, name, Name__c, Summary__c from QuestionType__c LIMIT 50];
return qType;
}
webService static Id insertQuestionType(QuestionType__c qType)
{
insert qType;
return qType.Id;
}
webService static Id updateQuestionType(QuestionType__c qType)
{
update qType;
return qType.Id;
}
webService static Id deleteQuestionType(Id id)
{
QuestionType__c[] removeQType = [select id, name, Name__c, Summary__c from QuestionType__c where id = :(id)];
String returnVar = removeQType[0].id;
delete removeQType;
return returnVar;
}
}
Thanks in advance...
Test methods cannot be used to test Web service callouts.Web service callouts are asynchronous, while unit tests are synchronous.