0

I have a custom class defined as follows but when i runs the test class, unable to get coverage for above class:

public class parent{

public class child {
   public string a;
   public string b;
}

}

Above class does not have any method other than defining custom class. my test class is as follows:

@isTest
static void testinnerClass(){
parent.child s = new parent.child();
s.a = 'x';
s.b = 'y';
}

1 Answer 1

1
  1. When you define any test class it should add Testmethod so that Salesforce can execute that method.

  2. You need to define get and set property for both property.

Apex Class:

public class parent{

public class child {
    public string a{get;set;}
    public string b{get;set;}
}

}

Test Class

@isTest
static void testinnerClass(){
parent.child s = new parent.child();
s.a = 'x';
s.b = 'y';
}
0

You must log in to answer this question.

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