Annotation Type AfterEachTest


@Retention(RUNTIME) @Target(METHOD) public @interface AfterEachTest
Annotation for procedures to run right after each test. This can be useful for tasks like ensuring certain mutable objects meet certain conditions prior to the next test test. If no such tasks are needed, this annotation is not needed.

For example, in SavingsAccountTest, you might want to ensure a SavingsAccount object has a certain minimum balance prior to the next test, and deposit enough money to cover any shortfall.

A procedure with this annotation ought to give some indication that it has successfully completed its assigned tear-down tasks, such as by writing a message to that effect to the console.

A procedure with this annotation should be public but not static. It will run after any procedures annotated BeforeAllTests, BeforeEachTest, Test, but before any procedure annotated AfterAllTests. That is guaranteed because I have written tests for this in the test class for TestRunner.

One test class may have more than one procedure annotated @AfterEachTest. But that's probably more trouble than it's worth.

In any case it's preferable for a test class to only have one procedure with this annotation, if any. Such a procedure may make calls to private helper procedures.

You may use any identifier the compiler allows, but it's recommended that it be something that clearly indicates what the procedure does, such as tearDown() or tearDownTest().

Since:
1.0
Author:
Alonso del Arte