9

I know that Salesforce is trying to push the developer console. Hence they removed the ability to see the code coverage in the classes view.

The problem is that when I open the developer console and click the test tab the "Overall Code Coverage" only shows the classes that at least have 1% code coverage.

The only option I have right now is going through the whole classes list manually. Is there a better way to check if a class has no tests ran against it?

5

You can run all tests from the Force.com IDE and view all results at once, but I suppose this isn't much different than the list view option.

If you want to do this programatically, you can utilize the Tooling API or Apex API to get this information, see How can I get code coverage programatically through Apex?.

It would be great if salesforce allowed us to SOQL the ApexCodeCoverage table which is seemingly what those APIs are reading from.

  • Thanks Phil, I run the tests through the IDE and at least I have every class in one view with the code coverage. I cannot sort it, but I don't have to make any click to find the 0% classes. – Jose Chama Sep 23 '13 at 17:22
5

To find classes without coverage:

  1. Go to Develop > Apex Classes.
  2. Click Create New View.
  3. Add a filter: Code Coverage contains 0%.
  4. Add a filter: Code Coverage less than 1.
  5. Save your report.

To check if your class is being called in tests:

If you have the Force.com IDE for Eclipse, you could search your whole org for MyClass. and make sure it is being used in some test classes. Of course the tests have to also pass to count for coverage.

  • Thanks Adrian, but the problem is that it is still manual. I can run all the tests and then click on each one of the classes and see if the code coverage is 0%. I need something that will give me the list of classes that are 0%. – Jose Chama Sep 23 '13 at 16:27
  • The code coverage has been removed from the view. I cannot do what you are saying anymore in my Sandbox. – Jose Chama Sep 23 '13 at 16:49
0

You can use the new tooling Api to snag code coverage for any given class, or trigger.

http://www.salesforce.com/us/developer/docs/api_toolingpre/api_tooling.pdf

specifically see pages: 15-16.

Note: MavensMate (for Sublime Text 3) can show you aggregate code coverage for all classes and triggers when tests are run.

Plug: Everyone should use MavensMate.

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.