10

Every test class on my org that has a TestSetup annotated method shows 0/n lines covered in the developer console (Where n is the number of lines in the annotated method).

I thought maybe this was just something it showed and didn't count against test coverage. But then I pulled out a calculator and added up all the lines showed/covered and got what the org is telling me my coverage was.

So I then took out the TestSetup lines from the total and divided again. I gained a few percentage points for org wide code coverage.

I feel like this is something obvious that shouldn't count against an orgs code coverage. So I am here checking to see if I am missing something.

I did find this earlier post, but I think the question was mis-understood.

4
  • I would file a bug report.
    – Adrian Larson
    Sep 1, 2016 at 15:01
  • @AdrianLarson would I have to start that through a support ticket? Or where would I go? Sep 1, 2016 at 15:07
  • Yes you need to log a case with SF support. Sep 1, 2016 at 16:39
  • 1
    I have a case pending. I will post my results here when I resolve with support. Sep 1, 2016 at 20:26

3 Answers 3

9

This has nothing to with @testSetup.

My answer from a similar question which is valid for this one also:

What could have happened is, test class was created without @isTest annotation (at this point the class has been added to the code coverage table) and @isTest was added later (but this doesn't remove the class from the table). This usually happens if you create test classes in Developer Console. Delete and recreate the class and make sure @isTest is added at the time of creation itself. Create the test classes through Force.com IDE, Mavensmate or from setup page. The test class should disappear from code coverage table.

4
  • This is indeed the problem, why it doesn't come off of the ApexCodeCoverage table after you later save it is with an isTest annotation is a mystery to me. Props Avinash. I am going to wait until I hear back from support and why it behaves this way prior to accepting to this. To see if I can add a more explicit answer as to what is going on. And if they plan on fixing this. Sep 2, 2016 at 20:08
  • @JesseMilburn, have you heard from the support team? I would like to know if they are planning to fix this.
    – Avinash
    Sep 8, 2016 at 15:36
  • I am talking to them this afternoon. I will post back with any findings. Sep 8, 2016 at 15:37
  • This has been escalated to the next level of support. Sep 22, 2016 at 15:10
4

This has been identified as a bug by Salesforce support and logged in known issues.

The workaround identified by Avinash does work for the time being.

0

Do you happen to be running the tests in a sandbox org? I've noticed this happening in some sandboxs. All methods in an @isTest class are excluded when pushing to production.

2

You must log in to answer this question.

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