How to test a SF webService?

We can simply initialize the webService class and invoke the webService method in APEX. 

Example:

@isTest
private class testMyWebService
{
  
  
  static testMethod void testMyWebSvc()
  {
      SampleApexWebSvc.AccountInfo act = new SampleApexWebSvc.AccountInfo();
      act.AcctName = 'test';
      act.AcctNumber = 123;
      SampleApexWebSvc.createAccount( act );
      
      Account[] a = [select AccountNumber from Account where AccountNumber = '123'];
      System.assertEquals(a.size(), 1);
  }
}


Reference: http://boards.developerforce.com/t5/Apex-Code-Development/Testing-APEX-Web-services/m-p/268557/highlight/true#M46798 

Comments

Popular posts from this blog

Updating SourceData/ Data Source of the Pivot Table

Salesforce.com migration tool - Deploying Weblink and migrating files with special characters

Information Architecture - Setup your term store to scale