|
|
|
Artima SuiteRunner |
Why |
Getting Started |
Tutorial |
Get Help |
Discuss |
Print |
Email |
First Page |
Previous |
Next
|
|
Sponsored Link •
|
|
Advertisement
|
Suites to Build a Tree of Suites
A Suite consists of zero to many test methods and zero to many sub-Suites.
As mentioned previously, a sub-Suite is merely a
Suite that is held in a composition relationship by another Suite. The referenced
Suite is called a sub-Suite of the referencing Suite.
The customary manner to create larger tests is to define focused Suite classes, then aggregate them
together as sub-Suites of other Suite classes. An entire test suite is then represented in memory
by a tree of Suite objects, starting at a base Suite whose execute method
kicks off a run of the entire suite of tests.
The account example
has a main Suite, called AccountTestKit, that has no test methods, only sub-Suites.
Its constructor
instantiates two Suite objects and adds them as sub-Suites to itself via
the addSubSuite method. AccountTestKit represents the full conformance
test kit for the com.artima.examples.account.ex6 package.
Here is the entire AccountTestKit class:
package com.artima.examples.account.ex6test;
import org.suiterunner.Suite;
public class AccountTestKit extends Suite {
public AccountTestKit() {
addSubSuite(new AccountSuite());
addSubSuite(new InsufficientFundsExceptionSuite());
}
}
Figure 2 shows the structure of the AccountTestKit in memory. AccountTestKit, the
base Suite in the tree, holds references to two sub-Suites.
These two sub-Suites, AccountSuite and InsufficientFundsExceptionSuite,
declare test methods but do not themselves contain sub-Suites.

Figure 2. The AccountTestKit is a tree of Suite objects.
When the Runner invokes execute on the
AccountTestKit object, execute first invokes
executeTestMethods on itself.
executeTestMethods uses reflection to discover that AccountTestKit has no test methods,
and returns. execute then invokes executeSubSuites, which invokes execute
on each of its two sub-Suites. The execute methods of each of those Suites ensures
that all test methods executed.
|
Sponsored Links
|