You need to sign in to do that
Don't have an account?
Sarisfdc
I have above code. I am not able to write test class for this..
Please tell me how to write test class for this. Iam not able to get the response from the HHTP in test class
Thanks
How to write test class for @future method using Httprequest
global class webportal { @future(callout=true) public static void Importwebportal() { string webportalURL = 'https://api.testtt.com/testtesttestttttt=json'; string webportalResponse = ''; // Instantiate a new http object Http h = new Http(); // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint HttpRequest req = new HttpRequest(); req.setEndpoint(webportalURL); req.setMethod('GET'); // Send the request, and return a response try { HttpResponse res = h.send(req); webportalResponse = res.getBody(); } catch (Exception ex) { System.debug('' + ex.getMessage()); } webportalImport wb= new webportalImport (); wb.Import(webportalResponse); } }
I have above code. I am not able to write test class for this..
Please tell me how to write test class for this. Iam not able to get the response from the HHTP in test class
Thanks
Here is an article on how to use it: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm