[SalesForce] Why do Methods marked @TestSetup in Classes marked @IsTest count against test coverage requirements

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.

Best Answer

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.