|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=RUNTIME) @Target(value=METHOD) public @interface AfterClass
If you allocate expensive external resources in a BeforeClass
method you need to release them
after all the tests in the class have run. Annotating a public static void
method
with @AfterClass
causes that method to be run after all the tests in the class have been run. All @AfterClass
methods are guaranteed to run even if a BeforeClass
method throws an
exception. The @AfterClass
methods declared in superclasses will be run after those of the current
class.
Here is a simple example:
public class Example {
DatabaseConnection database;
@BeforeClass public void login() {
database= ...;
}
@Test public void something() {
...
}
@Test public void somethingElse() {
...
}
@AfterClass public void logout() {
database.logout();
}
}
BeforeClass
,
Test
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |