
only times to consider using Test Enumeration are (1) when our framework
does not support Test Discovery and (2) when we wish to defi ne a Named Test
Suite (page 592) that consists of a subset of tests
6
chosen from other test suites
and the Test Automation Framework does not support Test Selection (page 403).
It is not uncommon to combine Test Suite Enumeration (see Test Enumeration)
with Test Method Discovery; the reverse is less common.
Implementation Notes
Building the Suite of Suites to be executed by the Test Runner involves two steps.
First, we must fi nd all Test Methods to be included in each Test Suite Object.
Second, we must fi nd all Test Suite Objects to be included in the test run, albeit
not necessarily in this order. Each of these steps may be done manually via Test
Method Enumeration (see Test Enumeration) and Test Suite Enumeration or
automatically via Test Method Discovery and Testcase Class Discovery.
Variation: Testcase Class Discovery
Testcase Class Discovery is the process by which the Test Automation Frame-
work discovers the Testcase Classes on which it should do Test Method Dis-
covery. One solution involves tagging each Testcase Class by subclassing a
Testcase Superclass (page 638) or implementing a Marker Interface [PJV1].
Another alternative, used in the .NET languages and newer versions of JUnit,
is to use a class attribute (e.g., "[Test Fixture]") or annotation (e.g., "@Testcase")
to identify each Testcase Class. Yet another solution is to put all Testcase
Classes into a common directory and point the Test Runner or some other
program at this directory. A fourth solution is to follow a Testcase Class
naming convention and use an external program to fi nd all fi les matching
this naming pattern. Whichever way we choose to perform this task, once
a Testcase Class has been discovered we can proceed to either Test Method
Discovery or Test Method Enumeration.
Variation: Test Method Discovery
Test Method Discovery involves providing a way for the Test Automation Frame-
work to discover the Test Methods in our Testcase Classes. There are two basic
ways to indicate that a method of a Testcase Class is a Test Method. The more
traditional approach is to use a Test Method naming convention such as “starts
with ‘test’.” The Test Automation Framework then iterates over all methods of
the Testcase Class, selects those that start with the string “test” (e.g., testCounters),
6
A Smoke Test [SCM] suite is a good example.
Test
Discovery
Chapter 19 xUnit Basics Patterns
394