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

test class for web serivces method

Hi this is my class am using this in one button

can you please any one tell me how to write test class for the web services method.


global class letter
    WebService static string letter(string id)
            Opportunity opp=[Select o.AccountId, o.Delivery__c,  from Opportunity o where];
            Quote Qt=new Quote();
            if(opp.Delivery__c!=null|| opp.Deliverys__c!='')
            insert Qt;
            return 'letter';
        catch(exception ex)
            return 'Error';


Thanks for your replay

Best Answer chosen by Admin (Salesforce Developers) 
try this

private class lettertest {

static testMethod void dolettertest()

opportunity opp = new opportunity(); = 'test record';
opp.Delivery__c = 'test delivery'

insert opp;