Please help me why my code coverage is showing 0% . See my class code and test class code where I have written wrong?


public class InnerClass {

    public class Wrap {
        public string Id;
        public string Name;        

Test Class

public class InnerClassTest {

    public static void wraper(){        
        InnerClass.Wrap w = new InnerClass.Wrap();
        System.assertEquals(null, w.Id);
        System.assertEquals(null, w.Name);       

A terminology point is that your InnerClass is the outer class and the Wrapclass is the inner class.

AFAIK simple property references are not counted in coverage. The real point of tests is to confirm the behavior. If you do that the code coverage will happen as a side effect.

If you want to see some code coverage, add a fak method with a few lines of code in it to the Wrap class and call that method from your test. Then remove that and get back to building the functionality you want.


Test coverage is calculated on the basis of executable lines:

Code coverage percentage is a calculation of the number of covered lines divided by the sum of the number of covered lines and uncovered lines. Only executable lines of code are included.

Your code is not technically uncovered; it is not coverable because it consists only of declarations, with no executable lines. You'll see in your coverage highlighting in Developer Console that these lines are white. This indicates they are not coverable lines and aren't included in your coverage calculation.

Your total coverage is zero because you have nothing to cover. Add executable lines, like a constructor, a method, or a property declaration, and you'll see nonzero coverage because those lines are executable.

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.