Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 5 down vote accepted

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).

share|improve this answer
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 '12 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 '12 at 6:34
There was a good post on the developer blog - How Code Coverage Works. It goes someway towards explainng how things can get out of phase. – Daniel Ballinger Dec 18 '12 at 9:13
Thanks. That makes a lot more sense. ;) – AMM Dec 18 '12 at 14:00
@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 '12 at 2:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.