Template method test pattern

A. Bijlsma, H.J.M. Passier, H.J. Pootjes, S. Stuurman

Research output: Contribution to journalArticleAcademicpeer-review

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.
Original languageEnglish
Pages (from-to)8-12
Number of pages5
JournalInformation Processing Letters
Volume139
Issue number2018
DOIs
Publication statusPublished - Nov 2018

Fingerprint

Template
Testing
Concretes
Industrial plants
Long-run
Class
Demonstrate

Keywords

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

Cite this

Bijlsma, A. ; Passier, H.J.M. ; Pootjes, H.J. ; Stuurman, S. / Template method test pattern. In: Information Processing Letters. 2018 ; Vol. 139, No. 2018. pp. 8-12.
@article{d39fac4bb97c48a4acb96beb41a8cabf,
title = "Template method test pattern",
abstract = "How to test abstract classes is an area of testing that is not paid much attentionto. 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 oneproduced by the Template Method pattern. This pattern results in an abstractclass, with a concrete template method and one or more abstract primitiveoperations, and one or more subclasses, implementing the primitive operationsspecifically for each subclass.How should we test an instance of the Template Method pattern? Testingthe concrete template method by testing the abstract class is impossible. Testingan instance of the Template Method pattern by testing the template method inall of the subclasses individually is error-prone in the long run.This paper presents a structured approach to test instances of the TemplateMethod pattern in an elegant way using the Abstract Factory pattern. Fur-thermore, we introduce the new conceptsemi-abstract methodto reason aboutconcrete methods that depend on abstract operations. We formalize the patternand demonstrate the approach at work using an example program.",
keywords = "Software testing, Software design and implementation, Abstract classes, Template Method",
author = "A. Bijlsma and H.J.M. Passier and H.J. Pootjes and S. Stuurman",
year = "2018",
month = "11",
doi = "10.1016/j.ipl.2018.06.008",
language = "English",
volume = "139",
pages = "8--12",
journal = "Information Processing Letters",
issn = "0020-0190",
publisher = "Elsevier",
number = "2018",

}

Template method test pattern. / Bijlsma, A.; Passier, H.J.M.; Pootjes, H.J.; Stuurman, S.

In: Information Processing Letters, Vol. 139, No. 2018, 11.2018, p. 8-12.

Research output: Contribution to journalArticleAcademicpeer-review

TY - JOUR

T1 - Template method test pattern

AU - Bijlsma, A.

AU - Passier, H.J.M.

AU - Pootjes, H.J.

AU - Stuurman, S.

PY - 2018/11

Y1 - 2018/11

N2 - How to test abstract classes is an area of testing that is not paid much attentionto. 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 oneproduced by the Template Method pattern. This pattern results in an abstractclass, with a concrete template method and one or more abstract primitiveoperations, and one or more subclasses, implementing the primitive operationsspecifically for each subclass.How should we test an instance of the Template Method pattern? Testingthe concrete template method by testing the abstract class is impossible. Testingan instance of the Template Method pattern by testing the template method inall of the subclasses individually is error-prone in the long run.This paper presents a structured approach to test instances of the TemplateMethod pattern in an elegant way using the Abstract Factory pattern. Fur-thermore, we introduce the new conceptsemi-abstract methodto reason aboutconcrete methods that depend on abstract operations. We formalize the patternand demonstrate the approach at work using an example program.

AB - How to test abstract classes is an area of testing that is not paid much attentionto. 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 oneproduced by the Template Method pattern. This pattern results in an abstractclass, with a concrete template method and one or more abstract primitiveoperations, and one or more subclasses, implementing the primitive operationsspecifically for each subclass.How should we test an instance of the Template Method pattern? Testingthe concrete template method by testing the abstract class is impossible. Testingan instance of the Template Method pattern by testing the template method inall of the subclasses individually is error-prone in the long run.This paper presents a structured approach to test instances of the TemplateMethod pattern in an elegant way using the Abstract Factory pattern. Fur-thermore, we introduce the new conceptsemi-abstract methodto reason aboutconcrete methods that depend on abstract operations. We formalize the patternand demonstrate the approach at work using an example program.

KW - Software testing

KW - Software design and implementation

KW - Abstract classes

KW - Template Method

U2 - 10.1016/j.ipl.2018.06.008

DO - 10.1016/j.ipl.2018.06.008

M3 - Article

VL - 139

SP - 8

EP - 12

JO - Information Processing Letters

JF - Information Processing Letters

SN - 0020-0190

IS - 2018

ER -