5

How can I check the cumulative line by line code coverage of an Apex class that is included in a managed package?

I have a dev org where I create a managed package. It has already gone through a number of iterations/releases. One of the classes that was generated by WSDL2Apex was significantly updated in the current release which caused the code coverage to drop.

I'd like to quickly check which lines aren't being tested in this class.

To do this I:

  • Pressed the Clear Code Coverage button on the Apex Classes page
  • Pressed the Clear Test Results button on the View Test History page
  • Pressed the Run All Tests button on the Apex Classes page and waited for the tests to complete.
  • Clicked the percentage that appeared in the Code Coverage column. Currently 73% in the screenshot below.

Apex Class Code Coverage Column

The resulting URL was: https://na2.salesforce.com/setup/build/viewCodeCoverage.apexp?id=01p40000000Gykn

But the page was missing any content beyond the navigation chrome.enter image description here

My first thought was that this used to work and that something has broken in Summer 13. I raised case 09533205 with support, but they insisted this works as designed and you can't see code coverage for an Apex class that is in a managed package. Even if you are in the packaging org that defines the class.

This does seem to be how it works, as the code coverage link only shows content for Apex classes that aren't in the managed package.


Updated: I have found alternative ways to check the code coverage.

  1. The developer console can see the same information, but it has a tendency to become unresponsive/hang for me.
    All Tests code coverage in the developer console
  2. I can also get code coverage data via the API, but I'd prefer not to create my own code coverage viewer.
  3. I can get code coverage for an individual test class by running it in Eclipse. This doesn't show the cumulative result of all the test cases.

So now the question becomes:

Should I be able to use the code coverage link for a managed package Apex Class in the packaging Org that defines it?

I was fairly certain this used to work before Summer 13. Salesforce support disagreed and said it worked as designed before closing the case.

4
  • 1
    Sounds like you're suffering the same problem that I posted an answer for here. I just checked our packaging org and got a blank screen as well. I do not recall ever checking code coverage inside the packaging org, so can't comment on whether it used to work. The fact you can get the information using other tools suggest to me it is broken Aug 5, 2013 at 23:48
  • @DanielBlackhall I couldn't reason enough with Tier 1 support to convince them this is a bug. They were convinced this works as designed and should be closed with the utmost expediency. It really shouldn't be so hard to raise a potential bug with Salesforce. Aug 6, 2013 at 0:02
  • 1
    I'm seeing this issue as well, and I'm 99% certain that it's new behavior. Within the past three weeks, I was viewing code coverage, in the packaging org, for classes included in a managed package. In my case, it's not the real release package, but an org set up for testing/development that I use to create test packages in an alternate namespace. Some tests rely on having a namespace, and this change is very frustrating.
    – tomlogic
    Aug 6, 2013 at 4:18
  • 1
    I can also confirm that in my org, I see coverage for classes that aren't in a released package, including classes that have only been in beta packages.
    – tomlogic
    Aug 6, 2013 at 4:22

2 Answers 2

4

This is listed as a Known Issue: https://success.salesforce.com/issues_view?id=a1p30000000SzHiAAK Unfortunately, its Status is No Fix: Salesforce Engineering Management determined that a fix for the issue is not possible.

1
  • Thanks, at least now I feel vindicated after my struggles with Salesforce Support that it wasn't just me experiencing this issue. Aug 6, 2013 at 2:22
0

There is one work around for this:

Copy the Apex class code and create a new Apex class and paste that code into it. Now write test class for this and when you are done with it ,Just paste that code into the main test class.

0

You must log in to answer this question.

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