Sponsored Link •
To create a test suite, you simply subclass
Suite and define test methods.
For example, for the account exampleI CTK I created class
and gave it three test methods.
As shown in Figure 1,
AccountSuite is a subclass of
Its three test methods are
Figure 1. AccountSuite extends Suite and defines test methods.
If your are familiar with JUnit, you can think of class
Suite as the
Test all collapsed into one type. Whereas JUnit uses the composite
pattern to combine test cases into test suites, Artima SuiteRunner uses plain old composition.
Any Artima SuiteRunner
Suite can hold references to other
A fixture consists of objects and anything else needed to perform a test.
In general, all test methods in a
share the same fixture, which is usually composed of objects
stored in private instance variables of the
Suite. You can create
fixtures in either of two ways, via the constructor of your
subclass or via
invoking each test method, and
each test method completes.
These methods can be used to create a fresh fixture
before each test method, and destroy it afterwards.
cleanupFixture methods are useful
when your test methods destroy or change the fixture.
If you are certain your test methods won't destroy the fixture, and you don't need to perform
any fixture cleanup, you can simply initialize the private variables that represent your fixture in
a constructor of your
cleanupFixture methods are similar to
teardown methods of JUnit's class
Unlike JUnit, however, Artima SuiteRunner's
Suite.executeTestMethods invokes all test methods on
(JUnit generally creates a different
TestCase instance for each test method.) If any of
your test methods destroy its fixture such that the fixture can't be used
by sibling test methods invoked later on the same
Suite object, you should
setupFixture to create the fixture.
setupFixture, you create the necessary objects and perform any other
tasks to ready the fixture, such as opening a file or socket. In
can release the objects to the whims of the garbage collector and perform
any other necessary cleanup, such as closing the file or socket.