So if I have a parent abstract class that is fully implemented except for the defining property number
:
abstract class DividesByFive
{
protected $number;
public function getResult()
{
return $this->number / 5;
}
}
When going to test things, I have multiple child classes based on the parent class.
I test the getResult
in my SevenDividedByFive
class.
Do you guys test the getResult
method for each of the implementations even though it is covered in our SevenDividedByFive
test?
Or do you just add tests for features that may differ in new children classes?
I would not even test that in the
SevenDividedByFive
class. Instead I would create a child class directly in the test file that inherits fromDividesByFives
and exists ONLY to be the single source where the methods actually implemented inDividesByFive
are tested, and only because of the technicality that you can't instantiate the abstract class directly.