Are there best practices for testing classes that use inheritance?
For example if I have a class BaseNode
public class BaseNode
{
int testInt;//attribute
//assume getters and setters and constructor
public function somethingComplicated()
{
//put complex code here
}
}
and another class called InputNode that inherits from BaseNode.
public class InputNode extends BaseNode
{
int secondTest;//attribute
//assume getters and setters and constructor
}
If I write getters and setters for both classes, what would I need to test?
Do you really have to write tests for getTestInt() in both the BaseNode and the InputNode classes? If you write a test for getTestInt() in the InputNode class does that automatically count as a test for the BaseNode class as well?
Edited question to make it more specific. I'm not just asking about getters and setters.
If you write a test for somethingComplicated() in the Base class do you automatically assume that the test is valid for the InputNode class?
I originally used getters and setters as a simple example to try and illustrate the concept. I didn't mean that I only wanted to test the getters and setters.