
593
test suite construction techniques to return a Test Suite Object (page 387)
containing only the specifi c Testcase Objects (page 382) we wish to execute.
When to Use It
Although we often want to run all the tests with a single command, sometimes
we want to run only a subset of the tests. The most common reason for doing so
is time; for this purpose, running the AllTests Suite for a specifi c context is prob-
ably our best bet. When our member of xUnit doesn’t support Test Selection
and the tests we want to run are scattered across multiple contexts and some
contexts contain tests we defi nitely don’t want run, we can use a Subset Suite.
Variation: AllTests Suite
We often want to run all the tests we have available. With smaller systems, it
may be standard practice to run the AllTests Suite after checking out a new code
base (to ensure we start at a known point) and before every check-in (to ensure
all our code works). We typically have an AllTests Suite for each package or
namespace of software so that we can run subsets of the tests after each code
change as part of the “red–green–refactor” cycle.
Variation: Subset Suite
Developers often do not want to run tests because they are Slow Tests (page 253).
Tests that exercise components that access a database will inevitably run much
more slowly than tests that run entirely in memory. By defi ning one Named Test
Suite for the database tests and another Named Test Suite for the in-memory
tests, we can choose not to run the database tests simply by choosing to run the
in-memory Subset Suite.
Another common reason given for not running tests is because the context
they need to run is not available. For example, if we don’t have a Web server
running on our development desktop, or if deploying our software to the Web
server takes too long, we won’t want to run the tests of components that require
the Web server to be running (they would just take extra time to run, and we
know they will fail and spoil our chances of achieving a green bar).
Variation: Single Test Suite
The degenerate form of a Subset Suite is the Single Test Suite, in which we instanti-
ate a single Testcase Object so that we can run a single Test Method (page 348).
This variation is particularly useful when we don’t have a Test Tree Explorer
(see Test Runner on page 377) available or when the Test Method requires some
Named Test
Suite
Named Test Suite