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

How to prepare your LOB app for Intune?

Information Architecture - Setup your term store to scale

Generate token signing .CER from ADFS Federation Metadata XML