Question

I have a series of PHPUnit tests to validate a class, "Class A".
I have another class, "Class B" which extends Class A.

Is there a good way to test that "Class B passes Class A's tests", or in other words "Class B behaves like Class A" without duplicating the test code?

I could test for the extends (using instanceof), but that seems like a misleading test.
I care that it behaves like Class A, not that it extends Class A, right? or wrong?

Was it helpful?

Solution

Just extend the PHPUnit test case of class A, for class B, that should do it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top