function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hramanihramani 

Extended Classes' Test Class

If a class extends to another class, should we separate test class for both or one test class is good enough to cover both the classes?

e.g.
public class ApplicationFormParseJSON extends ApplicationForm
{
// operation happens
}
Another Class :
public virtual class ApplicationForm
{
// operation happens
}

Do I need to write separate Test for the virtual class ApplicationForm ? or ApplicationFormParseJSONTest will be good enough?
Ajay K DubediAjay K Dubedi
Hi hramani,

You should create separate test class for both the class because class which you extend on the another class, It will not override all your method by default.so that you should use separate test class for both.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
hramanihramani

Thanks for the reply Ajay,

If I get the code coverage for both the classes in one test class itself, do I need to write a separate one?

Ajay K DubediAjay K Dubedi
Hi hramani,

If it works then no need to create separate test class for both.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi