concept inheritance in category junit

appears as: inheritce
JUnit in Action

This is an excerpt from Manning's book JUnit in Action.

6.2.7   Favor composition over inheritance

Many people choose inheritance as a code-reuse mechanism. I think that composition can be easier to test. At run time, code cannot change an inheritance hierarchy, but you can compose objects differently. What you strive for is to make your code as flexible as possible at run time. This way, you can be sure that it is easy to switch from one state of your objects to another, which makes the code easily testable.

It is safe to use inheritance within a package, where the subclass and the superclass are under the control of the same programmers. Inheriting from ordinary concrete classes across package boundaries may be risky.

Inheritance is appropriate only when the subclass is a subtype of the superclass. When you have to have classes, A and B, we may ask ourselves if we can relate them. Class B should extend class A only if an IS-A relationship exists between the two classes.

JUnit in Action, Second Edition

This is an excerpt from Manning's book JUnit in Action, Second Edition.

5.2.8. Favor composition over inheritance

Many people choose inheritance as a code-reuse mechanism. We think composition can be easier to test. At runtime, code can’t change an inheritance hierarchy, but we can compose objects differently. We strive to make our code as flexible as possible at runtime. This way we can be sure that it’s easy to switch from one state of our objects to another, and that makes our code easily testable.