+ Start a Discussion

How to write a test class for a Web service


Can anyone please guide me as to how do we write the test class for a Web Service.

Ajay Nagar 7Ajay Nagar 7
Go through these links :
Amit Chaudhary 8Amit Chaudhary 8
Please check below trailhead module for all webservice related qun.
1) https://developer.salesforce.com/trailhead/module/apex_integration_services?utm_campaign=trailhead&utm_source=sfdc&utm_medium=chatter-success

Apex Integration Overview
This module will Describe the differences between web service and HTTP callouts and Authorize an external site with remote site settings

Apex REST Callouts
This module will  describe about Perform a callout to receive data from an external service and Test callouts by using mock callouts 

Apex SOAP Callouts
This module will describe you about Generate Apex classes using WSDL2Apex and  Perform a callout to send data to an external service using SOAP with Test callouts by using mock callouts

Apex Web Services
This module will Describe the two types of Apex web services and provide a high-level overview of these services. Create an Apex REST class that contains methods for each HTTP method and Invoke a custom Apex REST method with an endpoint

NOTE:- Test class example ith Mock classes also given in above module

Let us know if this will help u