Annotation Type BeforeEachTest
For example, in SavingsAccountTest
, you might want to ensure
a SavingsAccount
object has a certain minimum balance prior to a
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 set-up 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
, but before any
procedures annotated Test
, AfterEachTest
or 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
@BeforeEachTest
. 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
setUp()
or setUpTest()
.
- Since:
- 1.0
- Author:
- Alonso del Arte