0

I am working on a unit test of a class in developer console.

My target is to achieve a certain level of coverage.

I am on edge of reaching my coverage target, so I need to know the number of lines covered in that class.

Whenever I make changes in the test class and complete the run, I go to Overall Code Coverage section and scroll to the class name and check how many lines are covered.

Is there any other quicker way to get the number of lines coverage for the class?

  • If you use the Intellij IDE with the Illuminated Cloud plugin, you can view code coverage in each class and you can see the lines that are not covered. Note that while the Intellij community edition is free, Illuminated Cloud is a paid plugin. – David Cheng Aug 4 '19 at 3:21
2

In the Developer Console, click on "Query Editor", then type in the query:

SELECT NumLinesCovered FROM ApexCodeCoverage WHERE ApexClassOrTrigger.Name = 'myClassName'

Then, check the "Tooling API" checkbox. Once you run the test, execute this query, and you'll get a result back. If you leave this tab open, you can simply click the "Rerun Query" button after a test run, and you'll get immediate results back without looking through the full list.

Note that "System.debug" lines are never covered or uncovered (they are simply ignored for this purpose).

|improve this answer|||||
  • This SELECT NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverageAggregate WHERE ApexClassOrTrigger.Name = 'myClassName' worked for me. Thanks – वरुण Aug 8 '19 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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