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 Sampl eApexWebSvc.AccountInfo();
act.AcctName = 'test';
act.AcctNumber = 123;
SampleApexWebSvc.createAccount( act );
Account[] a = [select AccountNumber from Acc ount 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
Example:
@isTest
private class testMyWebService
{
static testMethod void testMyWebSvc()
{
SampleApexWebSvc.AccountInfo act = new Sampl
act.AcctName = 'test';
act.AcctNumber = 123;
SampleApexWebSvc.createAccount( act );
Account[] a = [select AccountNumber from Acc
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
Post a Comment
Feedback - positive or negative is welcome.