开发者

PHPUnit, Testing "Behaves Like A..."

开发者 https://www.devze.com 2022-12-10 01:22 出处:网络
I have a series of PHPUnit tests to validate a class, \"Class A\". I have another class, \"Class B\" which extends Class A.

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开发者_JS百科 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消