A Pattern to Test Instances of the Template Method

Research output: Book/ReportTechnical reportAcademic


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.
Furthermore, we introduce the new concept \emph{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 languageEnglish
PublisherOpen Universiteit Nederland
Number of pages11
Publication statusPublished - 12 Apr 2017


  • Software testing
  • Software design and implementation
  • Abstract classes
  • Template Method


Dive into the research topics of 'A Pattern to Test Instances of the Template Method'. Together they form a unique fingerprint.

Cite this