function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
e.weetche.weetch 

Code Coverage Highlighting Wrong (Developer Console & Tooling API's ApexCodeCoverage)

I'm trying to determine where code coverage is lacking (on Production) so I can write new Test Cases, but the highlight feature in Developer Console seems to be breaking under certain circumstances...

After clearing test data & running all tests from Developer Console,
  1. Sometimes, under "All Tests", it's highlighting blank lines, or lines that only contain comments / braces / debugs, as covered (or uncovered), and failing to highlight code lines.
  2. Sometimes, when selecting a specific test, it's showing a % coverage, but not highlighting any lines one way or the other.

I ran
SELECT ApexClassorTriggerId,NumLinesCovered,NumLinesUncovered,Coverage,ApexTestClassId FROM ApexCodeCoverage
SELECT ApexClassorTriggerId,NumLinesCovered,NumLinesUncovered,Coverage FROM ApexCodeCoverageAggregate
against the Tooling API, and got the same results: blank/comment/etc lines included, code lines ignored, and entries along the lines of:
"NumLinesCovered": 555,
"NumLinesUncovered": 55,
"Coverage": {
"coveredLines": [],
"uncoveredLines": []
}
(i.e. empty arrays for coveredLines / uncoveredLines, which seems wrong given that it's just given counts of each of these.)


Oddly it seems to be highlighting correctly in Sandbox in at least some of the cases it's getting it wrong in Production... but getting a lower % overall coverage?
(There are quite possibly differences between Production and Sandbox that would cause this, though, hence my wanting to check coverage on Production.)


Has anybody else experienced this? Any thoughts on resolution?
Unfortunately, I'm not likely to get permission to post the code in question, and I suspect it'll take a fair amount of effort to replicate this.
Did consider a Sandbox refresh, but have a notion this might just break it in Sandbox too...


Thanks in advance!
AshlekhAshlekh
Hi, 

Compile all the classes again and the run all test and then verify in Developer console.

-Thanks
Ashlekh Gera
e.weetche.weetch
@AKG -- thanks for the suggestion, but it's still doing the same thing.
Amit Chaudhary 8Amit Chaudhary 8
Please try below App Exchange product. I hope that will help you
https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000DXzlpEAD

NOTE:- Please Start Run All Test then try to check your code coverage in console or in App.
e.weetche.weetch
@Amit Chaudhary 8
Thanks for the suggestion. Unfortunately, I'd need to go through approval to install this on our Production org.
I did write something similar using apex.js some time ago (predating Tooling API), but your interface is considerably nicer than mine!
I'd assume that if SF itself can't display the coverage correctly, nothing built upon the platform is going to be able to...

Just to confirm, I want to see covered / uncovered lines like the below, which your app doesn't seem to do?
The problem I'm having is that, for example, line 40 would be highlighted red / blue and line 37 would be left without highlight.
(Line 32 is presumably not highlighted because it's a continuation of line 31; I wonder if this behaviour might explain what I'm getting.)
Dev Console code coverage example
(from https://help.salesforce.com/apex/HTViewHelpDoc?id=code_dev_console_tests_coverage.htm&language=en, when linkrot inevitably occurs)