0

This is probably overly obvious, but I do not wish to assume, and I am finding no reference anywhere:

What does the COLOR CODING when viewing percentage coverage on a Trigger mean? Some code is plain black on white, some is backgrounded with either blue or red.

Since some of the blue refs AND some of the red refs have mention of things that are NOT just my own defined variables, I'm confused as to the implication of the red and blue (my belief ius BLUE is eligible for code coverage/testing, and red is not, or vice versa).

Thanks for any insights.

Screenshot of coloring

1 Answer 1

5

http://www.salesforce.com/us/developer/docs/workbook/Content/apex_testing_5.htm

The blue highlight marks lines of code that have been covered (executed) as a result of our test method. The red highlight marks lines that have not been executed.

White lines are excluded from calculations (comments, closing braces etc "unimportant" things Salesforce skips when calculating code coverage).

6
  • 2
    This is correct, but it's also worth mentioning that I've seen numerous bugs in the highlighter over time - lines highlighted in blue that could not possibly have been executed, highlight off by a line or two for big chunks of code, covered lines not adding up to the reported percentage. It's a useful tool to show you portions of code that you may have thought were executed but weren't, but the reported % is the gospel.
    – jkraybill
    Dec 18, 2012 at 0:45
  • 100% correct, I use it as a quick&dirty indicator... Running tests in Eclipse is somewhat better (but can be also lying if you have tests hanging from Setup -> Run all tests?). No idea what the hell, as it'd be counting semicolons or newline characters in a weird way.
    – eyescream
    Dec 18, 2012 at 6:34
  • There was a good post on the Force.com developer blog - How Code Coverage Works. It goes someway towards explainng how things can get out of phase. Dec 18, 2012 at 9:13
  • I'm obviously lost. I may need to post a new Question about this, because I cannot get past 74% (72% in the class in question) after my latest Trigger update. I honestly am a hack when it comes to Classes (and only barely above that level with Triggers in general). Thanks again.
    – AMM
    Dec 18, 2012 at 15:31
  • 1
    @AMM - if you are stuck on a single class's coverage, you may get some help if you post a detailed question on your class, including the coverage red/blue screenshot. Just don't post a "please get me to 75%" question - make sure you cover what you've tried, what you're stuck on, etc.
    – jkraybill
    Dec 19, 2012 at 2:58

You must log in to answer this question.

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