Maybe I am remembering wrong but I think things have changed and I missed the document. Back to basics with this question
For a class that has no methods and is just ENUMS:
public class muENUMS{ //does not even show up in test coverage not even as 0/0 lines
public enum anExample{
TryMe,
YetAgain
}
}
Salesforce says there are 0 lines to cover (in fact it never even appears in list of classes that can be covered) and during tests nothing is ever covered despite the enums being used.
Another example without enums:
public class coverageExample{ //Shows as 1 of 2 lines covered just by instantiation
public String thisLineNotCountedOrCovered;
public String thisLineCountedAndCovered = 'A String';
public String thisLineCountedAndNOTCovered {get; set;}
}
So my questions in the context of just instantiating the class):
- Has this always been the case?
In the enum class no coverage data is calculated and the lines do not count toward to total lines to cover
In the other class it counts as 1 of 2 lines covered. The first property is not counted nor covered. The one with the getter / setter is counted and not covered.
- If it has not always been the case, can someone point me to the document that outlines the change? Google failed me.
It seems if a property is defaulted to a value it counts as a line of code to cover and gets covered. If a line is just a property declaration without a getter / setter it is not even considered for coverage. If it is declared with a getter / setter it is counted and if not accessed it is not covered
I believe it is important to understand this as it really impacts the access the developer gives code. Many are used to just adding getters / setters even if they are not needed. In the above that decision creates unnecessary coverage requirements.