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
aaryansriaaryansri 

Mock Response for Testing Web Service Callouts

Hi

  I need Mock Response for Testing Web Service Callouts and  test class for below  webservice code can some body help on that the class code covrage is showing 0%.


//Class used to get component record ID to be used in custom buttons without hardcode.//

Global without sharing class GetComponentId{  
WebService static string GetIDbyComponentName(String ComponentName, String ComponentType) {       
   if(ComponentType == 'Report'){        
   String ComponentId = [SELECT Id FROM Report WHERE DeveloperName = :ComponentName LIMIT 1].Id;         
  return ComponentId;     
}else
{            String ComponentId = 'error';  
         return ComponentId;      
  }
  }
}
Ramu_SFDCRamu_SFDC
See if the below article gives you any lead

http://learningthecloudway.blogspot.co.uk/2013/10/how-to-create-mock-http-response-in.html