Skip to main content
Hi All,

how can i cover http resonce in code coverage am facing this Error while running the Test class "Methods defined as TestMethod do not support Web service callouts"

               Http htp = new Http();

                HttpRequest req = new HttpRequest();

                req.setEndpoint(ENDPOINT);

                req.setMethod('GET'); 

                HttpResponse res = new HttpResponse();

                res = htp.send(req);

Thanks.
3 Antworten
  1. 3. Jan. 2017, 09:06
    Hi anu,

    Http htp = new Http();

                    HttpRequest req = new HttpRequest();

                    req.setEndpoint(ENDPOINT);

                    req.setMethod('GET'); 

                    HttpResponse res = new HttpResponse();

    if(test.isRunningTest()){

                    res = htp.send(req);

    }else{

    res = ''; //Dummy Response

    }

    if answer help you then mark it best answer.

     
0/9000