2

We are getting strange behavior with the Developer Console when running our unit tests. We complete development with the force.com IDE and use the dev console for unit testing (for performance & the code highlighting).

Here are the steps I am taking:

  1. After saving a class to the server I recompile all classes.
  2. I then run all tests in the developer console.
  3. After the tests have completed I am finding that the lines counted on some of the classes are incorrect, if I open the test class from the coverage pane in the console it has around 150 lines, but in the test coverage panel it shows 30/34 lines being tested.

Interestingly the highlighting is failing to highlight lines that haven't been tested and oddly they are not counting to the line total for that class.

enter image description here

A work colleague is encountering the same issue in his org - although the line counts he gets in his org (in dev console) are slightly different. We work on the same code base and the classes that we noticed this on are exactly the same. He performs the same 3 steps.

Anyone know how we can get an accurate picture of our org wide code coverage?

1 Answer 1

2

This is normal. The count of lines is the number of executable statements in a class. From the docs:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_code_coverage_intro.htm

How Is Code Coverage Calculated?

Code coverage percentage is a simple calculation of the number of covered lines divided by the sum of the number of covered lines and the number of uncovered lines. Only executable lines of code are included. (Comments and blank lines aren’t counted.) System.debug() statements and curly brackets are excluded when they appear alone on one line. Multiple statements on one line are counted as one line for the purpose of code coverage.

So you should expect to see a significant decrease between the raw number of lines in the class file and the numbers being reported after a test run.

1
  • Looking at the class this makes sense. Thanks for the link - I missed that one.
    – Jim
    Mar 26, 2015 at 22:24

You must log in to answer this question.

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