I am having an issue, for the last couple of days and I dont know how to fix it.

I have run all the test classes in production, when I open my developer console, the overall code coverage is 79% (of all production). I have created a test class that covers 2 classes that weren't covered before, raising the code coverage for 1 class to 100% and the second class to 92% I am trying to deploy this test class, but I am getting an error saying that overall code coverage is 73%.

This doesn't have any sense, as this new test class are over 90%, if my overall is 79% this should actually increase my coverage not decrease it.

Is there anything that I am missing? or is there another way to find out overall code coverage, and my developer console is giving me the wrong overall?

  • Are you just trying to deploy the test class?
    – EricSSH
    Commented Mar 24, 2015 at 22:43
  • yes, just the test class
    – manza
    Commented Mar 24, 2015 at 23:53
  • I would open a ticket with SFDC Support, sometimes the code coverage reported can be buggy. The below troubleshooting steps should of course also be followed.
    – Eric Clay
    Commented Mar 25, 2015 at 14:11
  • Thank you for your comment, i have tried twice but it is really frustrating salesforce keep closing the ticket "Please be informed that Developer support is currently available only to our premier customers and Premier partners ...." so annoying, it seems impossible to report a bug
    – manza
    Commented Mar 25, 2015 at 22:31
  • 1
    Support really sucks. No chance. Even in case of bugs and serious failures on their and you get that single response.
    – Uwe Heim
    Commented Mar 26, 2015 at 0:21

4 Answers 4


This is a very general question, so I can only respond with a generic answer.

You might verify the following:

  • Are the two classes to be tested identical on production and sandbox/devOrg?
  • since it's the overall coverage: do other classes differ?
  • do you use seealldata=true? If so, coverage is dependent on data and other parts of your code might be triggered.
  • If possible, try to use seealldata=false
  • make sure that all triggers are identical. During tests and DML triggers might fire.
  • try to deploy all trigger, classes and tests at the same time (e.g. ctrl-select the classes and triggers root nodes in eclipse and then deploy)
  • do you use any hardcoded ids? E.g. for recordtype detection, etc?
  • is the api version in the xml files the same for all classes and triggers to their counterpart on production?
  • do you have identical workflows on sand and prod? Also thy can fire and cause other tiggers to be invoked.
  • try/catch can be very tricky: if your code fails inside a catch, the tests won't fail but silently skip large parts of your code
  • Hi Uwe, Thank you for your reply code is the same we have a repository for production and sandbox and the only differences is the test classes that I am trying to deploy. I dont think we have any hardcode but it is hard to tell at this point as we have a lot of classes, however if we do hardcoded and they were wrong, the test classes in production will fail, and this is not happening. Very interesting about try catch, but if this happen overall code coverage will be affeceted right? or it will still display high code coverage when is not?
    – manza
    Commented Mar 25, 2015 at 22:29
  • If it fails inside try/catch the test will succeed but coverage might go way down. This happens very silently. It happened once to me where I had lots of empty catches.
    – Uwe Heim
    Commented Mar 26, 2015 at 0:13
  • Thanks Uwe, that is what I supposed, the main thing that concerns me is that when I run all the test class in production they all pass. Your suggestions are awesome, very complete, but code covergae in production should be lower if I was having any of the above issues
    – manza
    Commented Mar 26, 2015 at 0:17
  • That was my understanding: you're getting 73% instead of 79%. Did I get this wrong?
    – Uwe Heim
    Commented Mar 26, 2015 at 0:27
  • Hi Uwe, when I run all the test classes in production the overall coverage is actually 82% (i wrote 79% by mistake), when i validate the test class the validation fail and the error that i get is my production coverage is 73%, so that is why I am thinking it must be a salesforce error
    – manza
    Commented Mar 26, 2015 at 0:59

I am almost 100% sure that SF has changed functionality which checks code coverage.

Check my answer here: https://developer.salesforce.com/forums?id=906F0000000B27eIAC

  • SImon, if I got this right, it seems that commented lines DO count? They should not. I would consider it as a bug and expect that it will be changed back at some point in the future. IMO it does not make sense to count comments. Comment lines should be ignored.
    – Uwe Heim
    Commented Mar 25, 2015 at 14:29
  • No, I didn't mean that comments count, but there is a change which caused that variables aren't covered outside methods if they aren't set in any method...
    – Simon
    Commented Mar 25, 2015 at 18:20

So, it seems it was a real salesforce issue.

For some reason the code coverage that was display in the developer console was wrong. I followed the following steps and then the developer console change from 82% to 68%. It seems that was feeding somehow the overall coverage from historic test classes run.

I keep saying it was an issue as after doing this I was allow to deploy test classes that improve code coverage, even that the outstanding overall after the deployment was below the 75%. (After I deploy my one test class and rerun the test, the overall coverage went up to 72%) when before i wasnt able to do this. Not sure if Salesforce did something a few days before.

Anyway, I follow the following steps to get the real coverage


I skipped the step 2, as this throws me an sObject error (not found)

ALso I found this interesting issue, somehow related as test coverage that was taking long seems to be lost:



Unfortunately this appears to be a bug but not in the way SF is currently tracking it. They have acknowledge that their is a bug with Code Coverage in the developer console but not in the terms that we are all discovering. I currently have a ticket open and a couple insiders at SF looking closely into this to hopefully get it resolved soon.

Check out my full question and explanation here: Develop Console Code Coverage Issues (Winter 15' Release) - Production vs. All Test

At the moment there is a patch for what they consider "the bug" scheduled for October, but if we can continue to unveil the issue and its bigger than they expect then they may consider pushing that sooner.

As you'll see in my response (updating as more details come), there is a work around at the moment, (annoying) at least to get your sandbox to show you accurate code coverage. Keep in mind what Uwe mentioned about debugging your test and know that there is a difference between perceived code coverage (running all test) and actual code coverage which happens during deployment

For more details about what they consider to be a bug follow this: https://success.salesforce.com/issues_view?id=a1p30000000T4oRAAS

Hope that helps, follow my post as well as I will be posting updates as I have them as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .