I have created test class for apex class in my developer account.

1) Create a global test class which implements HttpCalloutMock

global class WebServiceCalloutExampleCalloutMock implements HttpCalloutMock{  
global HttpResponse respond(HTTPRequest req){
    HttpResponse res = new HttpResponse();
    return res;

2) Test Class for your Apex Class

private class WebServiceCalloutAccount_Test {  
static Account getTestAccount(){
    Account myAcc = new Account(Name = 'Test');
    insert myAcc;
    return myAcc;

private static testMethod void callFutureMethod() {        
    Account a = getTestAccount();

    Test.setMock(HttpCalloutMock.class, new     WebServiceCalloutExampleCalloutMock());


3) Actual apex class

public class WebServiceCallout {
@future (callout=true)
public static void sendNotification(String id) {
    Http http = new Http();
    HttpRequest req= new HttpRequest();
    HttpResponse res = new HttpResponse();
    req.setBody('id='+EncodingUtil.urlEncode(id, 'UTF-8'));
    HttpResponse response = http.send(req);

When I run test for "WebServiceCalloutAccount_Test" (point 2) it gives result : Tests method passed and code coverage for "WebServiceCallout" (point 3) is 100% which shown in developer console.

Then I tried to deploy apex class "WebServiceCallout" (point 3) using eclipse to my production organisation it gives warning "0% coverage" and not deployed.

Can anyone say me what is the problem?

  • Did you try to deploy code coverage as well?
    – kurunve
    Commented Feb 9, 2017 at 11:50
  • No I tried to deploy only apex class Commented Feb 9, 2017 at 11:52
  • How can I deploy code coverage? Commented Feb 9, 2017 at 11:53
  • 3
    You have to select all three files at once, right-click, choose Deploy To Server, and enter your production credentials. If you do this right, it should deploy okay.
    – sfdcfox
    Commented Feb 9, 2017 at 11:54
  • 2
    Side note: req.setCompressed should be before http.send(req).
    – sfdcfox
    Commented Feb 9, 2017 at 11:54


You must log in to answer this question.

Browse other questions tagged .