Abstract
How to test abstract classes is an area of testing that is not paid much attention
to. Abstract classes cannot be instantiated and therefore standard execution-
based test strategies are not applicable.
In this paper, we consider a special case of an abstract class, namely one
produced by the Template Method pattern. This pattern results in an abstract
class, with a concrete template method and one or more abstract primitive
operations, and one or more subclasses, implementing the primitive operations
specifically for each subclass.
How should we test an instance of the Template Method pattern? Testing
the concrete template method by testing the abstract class is impossible. Testing
an instance of the Template Method pattern by testing the template method in
all of the subclasses individually is error-prone in the long run.
This paper presents a structured approach to test instances of the Template
Method pattern in an elegant way using the Abstract Factory pattern. Fur-
thermore, we introduce the new concept
semi-abstract method
to reason about
concrete methods that depend on abstract operations. We formalize the pattern
and demonstrate the approach at work using an example program.
to. Abstract classes cannot be instantiated and therefore standard execution-
based test strategies are not applicable.
In this paper, we consider a special case of an abstract class, namely one
produced by the Template Method pattern. This pattern results in an abstract
class, with a concrete template method and one or more abstract primitive
operations, and one or more subclasses, implementing the primitive operations
specifically for each subclass.
How should we test an instance of the Template Method pattern? Testing
the concrete template method by testing the abstract class is impossible. Testing
an instance of the Template Method pattern by testing the template method in
all of the subclasses individually is error-prone in the long run.
This paper presents a structured approach to test instances of the Template
Method pattern in an elegant way using the Abstract Factory pattern. Fur-
thermore, we introduce the new concept
semi-abstract method
to reason about
concrete methods that depend on abstract operations. We formalize the pattern
and demonstrate the approach at work using an example program.
Original language | English |
---|---|
Pages (from-to) | 8-12 |
Number of pages | 5 |
Journal | Information Processing Letters |
Volume | 139 |
Issue number | 2018 |
DOIs | |
Publication status | Published - Nov 2018 |
Keywords
- Abstract classes
- Software design and implementation
- Software testing
- Template Method