You need to sign in to do that
Don't have an account?
Hi, I need to cover method returning Blob type data in code coverage. Require urgent help on this.
public Blob getURLAttachment(string docurl){
String remoteContentURL=docurl;
Http http=new Http();
Httprequest request=new Httprequest();
request.setEndpoint(remoteContentURL);
request.setMethod('GET');
request.setTimeout(120000);
Httpresponse response= http.send(request);
Blob remoteContentAsBlob=response.getBodyAsBlob();
return remoteContentAsBlob;
}
String remoteContentURL=docurl;
Http http=new Http();
Httprequest request=new Httprequest();
request.setEndpoint(remoteContentURL);
request.setMethod('GET');
request.setTimeout(120000);
Httpresponse response= http.send(request);
Blob remoteContentAsBlob=response.getBodyAsBlob();
return remoteContentAsBlob;
}
You need use HttpCalloutMock and setup failed callout response
Please read documentation aboud it https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks,
Alex