While trying to upload our package (as an ISV partner) I noticed the following readings:

  • Upload failed due to 73% code coverage (of course... we need 75%) enter image description here

  • From the "Apex Classes" screen, after asking to calculate/estimate code coverage I get "Code Coverage: 61%"

enter image description here

  • And after running all tests in the developer console, I see that I have a code coverage of 76% which should allow me to upload

enter image description here

Am I doing something wrong?


1 Answer 1


I just had a very similar issue. I had a small Apex class where I was certain the code coverage was at, or at least very close to, 100%.

However, the developer console was reporting that it had only 60% coverage. Also, the code coverage lines weren't lining up in a meaningful way with the actual body of the Apex class. It was showing coverage over comment lines and nothing for several of the later lines in the class.

This lined up with the symptoms of the known issue Updating an Apex class through Metadata API makes its code coverage corrupt. After I deleted the ApexCodeCoverageAggregate records in the org and reran the tests the code coverage successfully reset to 100%.

So I'd suggest deleting those records and running all the tests again. It is likely that the process creating the managed package is independent of the ApexCodeCoverageAggregate records.

In addition to the known issue above this is also the knowledge article: Code coverage steps and considerations prior to deployments. This also covers deleting the ApexCodeCoverageAggregate records.

  • Thanks Daniel, although I am not updating apex classes through metadata API , I am using online editing (using SalesFoce Dev Env.) to update apex classes or any other entity (trigger/page etc)
    – Uri Lukach
    Commented Apr 29, 2015 at 11:27
  • @Uri Did clearing the ApexCodeCoverageAggregate records using the tooling API before running the tests resolve the issue? Commented Apr 29, 2015 at 19:31

You must log in to answer this question.

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