1

In developer Console all my classes are showing test coverage greater than 80%. But when I look at overall test coverage on ApexClasses page it shows at 74%. Any suggestions how is this calculated or why is it showing so less. Here is the screenshot showing coverage

3
  • Did you check for triggers as well in the console?
    – highfive
    Commented Apr 8, 2014 at 12:49
  • yes they are 100% covered
    – Sonal
    Commented Apr 8, 2014 at 12:54
  • 1
    Have you clean the test result and then execute all of the test class again ?
    – Cray Kao
    Commented Apr 8, 2014 at 16:17

2 Answers 2

1

The brilliant Josh Kaplan posted a thorough blog on this a while back. Gives you all the information you need.

0

This Link will help you..

Workaround 1. Identify all classes that have 0% code coverage. -- If you do not keep a list of tested and untested classes, you can use the tooling API to retrieve the list -- Easiest way is to log in to Salesforce via workbench.developerforce.com -- Under Utilities -> REST Explorer, paste in the following REST URL and execute (without line breaks):

/services/data/v29.0/tooling/query/?q=SELECT+ApexClassOrTriggerId,+ApexClassOrTrigger.Name,+NumLinesCovered,+NumLinesUncovered+FROM+ApexCodeCoverageAggregate ++WHERE+NumLinesCovered+=+0+AND+NumLinesUncovered+!=+NULL+ORDER+BY+ApexClassOrTrigger.Name

  • Click on Show Raw Response to see the list Ids and names of effected classes. (OR)

link Found what was wrong with my coverage. There were no test classes written for a part of the project, so those classes never got called in any test class which lead to them being omitted from the list of classes covered and therefore them not being counted towards Overall coverage.

However, while uploading a package, after tests were run some classes didn't have any coverage at all which lead to Overall coverage being so low.

After writing a few more test classes(for the classes that were not tested), I got the coverage above 75%.

So if there are no test classes testing some class A, then this class A will neither show up in Overall Code Coverage class list, neither count towards it.

Regards, Praveen Murugesan.

You must log in to answer this question.

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