Java interfaces, abstract classes, and superclasses

With the Rational Developer products you can create something called an abstract test that can be reused to test all classes that implement an interface, extend an abstract class, or inherit from a superclass.

Java interfaces and abstract classes cannot really be tested on their own because no objects of these types can be instantiated. The only way to really test these objects is to test the classes that implement the interface or extend the abstract class.

The Rational Developer products provide a test pattern that is intended specifically for this purpose. When you create a test with this test pattern, it creates an abstract test. An abstract test cannot be run on its own and does not include a test suite. To run an abstract test, make the test concrete, that is, apply the abstract test to a public class that implements the interface, extends the abstract class, or inherits from the superclass. You can make an abstract test concrete at the time of test creation if there are implementing classes available or any time after the abstract test has been created by using the "Apply an existing abstract test" feature.

 

Inherited classes

Although all tests defined for a superclass are applicable to the classes that inherit from the superclass, it is recommended that you test each inherited class individually. You can use the abstract component test pattern to create an abstract test of the superclass and apply that test to each class that inherits from the superclass.

 

Related tasks

Implementing an existing abstract test
Creating abstract Java tests