All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface org.ajug.jsl.jester.cases.Test

public interface Test
This interface it the main plugpoint for all tests. Any implementation will have appropriate methods called by the rest of the testing framework. For your convenience we provide TestCase, which has a default implementation for all methods.

Suite design can exploit the treeness of Test. The designer can design small suites that can be composed into larger suites that can be assembled into a huge suite that is a large product's full regression test. A development in product areas proceeds, the small suites can be run on those areas frequently, while the full suite would be run only perhaps daily, when all work has been integrated. This is all highly flexible, due to the design of the org.jsl.autotest.cases package.

Good test design can lead to high test reuse. For example, a Test generally has no idea who its parent is. A test can be used in different containers, and can even behave differently by using properties the different container provide.

Note the isContainer() and getChildTests() methods. This allows a Test to be a container or leaf, simplifying the framework. It also lets you suddenly decide to change a leaf into a container, with very little code work. This allows test suites to evolve more gracefully. It even allows a Test to dynamically decide to be a leaf or container during a session.

Note that all Test "delegates" are provided, such as Asserter. This allows the framework more control and flexibility, such as customizing different delegates and changing them from classes to interfaces.

See Also:
TestCase

Method Index

 o afterTest()
Called after runTest() is called.
 o assert(boolean)
Asserts that the boolean expression is true.
 o assert(boolean, String)
Asserts that the boolean expression is true.
 o beforeTest()
Called before runTest() is called.
 o getChildTests()
Lists all the child tests if any.
 o getTestContext()
Returns the TextContext, which should never be null.
 o getTestInfo()
Returns the TestInfo, which should never be null.
 o isContainer()
Indicates if the test is a container with children or not.
 o runTest()
This is your golden opportunity to run the tests you desire.
 o setAssertDescription(String)
Sets the description to be used if an AssertFailureException is thrown.
 o setTestContext(TestContext)
Sets the context for the Test.
 o setTestInfo(TestInfo)
Sets the TestInfo the Test uses to publish information about itself.

Methods

 o setTestContext
 public abstract void setTestContext(TestContext testContext)
Sets the context for the Test. The context is the only way the test can reach the outside world, the main purpose of the Context Pattern. Each test has its own unique context, which cannot be null.

If the test sets properties this must be done within this method. This allows passing container properties to their children before a test's beforeTest() is called.

 o getTestContext
 public abstract TestContext getTestContext()
Returns the TextContext, which should never be null.

 o setTestInfo
 public abstract void setTestInfo(TestInfo testInfo)
Sets the TestInfo the Test uses to publish information about itself. It cannot be null.

 o getTestInfo
 public abstract TestInfo getTestInfo()
Returns the TestInfo, which should never be null.

 o beforeTest
 public abstract void beforeTest()
Called before runTest() is called. This is an opportunity to set up test fixtures.

 o runTest
 public abstract void runTest()
This is your golden opportunity to run the tests you desire. In most cases this method will call further methods, such as testThis(), testThat(), or testUniversalSocket().

If multiple test methods are called, one must be careful that they don't mess up the shared state, causing some test methods to behave improperly. One way to resolve this is to reinitialize the shared state that could be affected before each test method. We shall see what's best as the framework evolves....

If the Test is a container this method is called before its children are used, ie before they have their beforeTest, runTest() and afterTest() called.

 o afterTest
 public abstract void afterTest()
Called after runTest() is called. Any outstanding resources should be released.

 o isContainer
 public abstract boolean isContainer()
Indicates if the test is a container with children or not. Most Tests are not a container. The testing framework uses the terminology of "container" and "leaf", A Test may be either, allowing great flexiblity and a far more simple, lightweight framework.

 o getChildTests
 public abstract Enumeration getChildTests()
Lists all the child tests if any. If isContainer() returns false then this method is never called. To speed testing the implementation should wait until the first time this method is called to create the child tests and the collection they are stored in. This method can be called multiple times at any time.

Returns:
an enumeration of objects implementating Test. They will be run in the order provided. For each call to getChildTests() the children must be the same instances. If the Test is a leaf then this returns null and is never called.
 o assert
 public abstract void assert(boolean isTrue)
Asserts that the boolean expression is true. If true it does nothing. If false an AssertFailureException is thrown. The exception message will be the assert description in effect or a standard one like "Assert failure" if none in effect.

See Also:
setAssertDescription
 o assert
 public abstract void assert(boolean isTrue,
                             String description)
Asserts that the boolean expression is true. If true it does nothing. If false an AssertFailureException is thrown containing the description. The description overrides the other one provided in setAssertDescription(String), if any. The description does not change the assert description in effect.

See Also:
setAssertDescription
 o setAssertDescription
 public abstract void setAssertDescription(String description)
Sets the description to be used if an AssertFailureException is thrown. The description remains in effect until reset or set to null.

See Also:
assert

All Packages  Class Hierarchy  This Package  Previous  Next  Index