You need to sign in to do that
Don't have an account?
Nishad Basha
above code how to write the test class so far.please give some ideas.
how write the test class for restservice?
@RestResource(urlMapping='/MyAccount12/*') global with sharing class MyAccountRest { @HttpDelete global static void doDelete() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); Account account = [SELECT Id FROM Account WHERE Id = :accountId]; delete account; } @HttpGet global static Account doGet() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId]; return result; } @HttpPost global static String doPost(String name, String phone, String website) { Account account = new Account(); account.Name = name; account.phone = phone; account.website = website; insert account; return account.Id; } }
above code how to write the test class so far.please give some ideas.
Please check below sample code for write the test class for REST webservice.
Test Class:
Let me know if you have any question on this.
Thank You,
Hitesh Patel
Email :- hiteshpatel.aspl@gmail.com
http://mrjavascript.blogspot.in/
above test class is not working please give another code
can you please post error here?
Use this.
Use test.StartTest() and Test.StopTest() to make callout.