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
manojjain4328manojjain4328 

How to write test code(test class and test methods) for webservice class

Hi all,

       

I have developed apex web service class  which is further used by the flex page for insert ,update,delete,update in Salesforce.

My question is for if i want to deploy my application in appexchange then i need to write test class and method for my apex code.

So that i could deploy my application into Appexchange.

 Please guide me what should be the suitable test class code for my web service class.

I have mentioned sample code for my web service class below:

 

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 = :smileysad: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 = :smileysad:id)];
String returnVar = removeQType[0].id;
delete removeQType;
return returnVar;
}
}

 

Regards,

Manoj Jain 

 

 
24-2010 12:12 AM