Annotation Interface AfterSuite
@AfterSuite
is used to signal that the annotated method should be
executed after all tests in the current test suite.
Method Signatures
@AfterSuite
methods must have a void
return type, must
be static
and must not be private
.
Inheritance and Execution Order
@AfterSuite
methods are inherited from superclasses as long as they
are not overridden according to the visibility rules of the Java
language. Furthermore, @AfterSuite
methods from superclasses will be
executed after @AfterSuite
methods in subclasses.
The JUnit Platform Suite Engine does not guarantee the execution order of
multiple @AfterSuite
methods that are declared within a single test
class or test interface. While it may at times appear that these methods are
invoked in alphabetical order, they are in fact sorted using an algorithm
that is deterministic but intentionally non-obvious.
In addition, @AfterSuite
methods are in no way linked to
@BeforeSuite
methods. Consequently, there are no guarantees with regard
to their wrapping behavior. For example, given two
@BeforeSuite
methods createA()
and createB()
as well as
two @AfterSuite
methods destroyA()
and destroyB()
, the
order in which the @BeforeSuite
methods are executed (e.g.
createA()
before createB()
) does not imply any order for the
seemingly corresponding @AfterSuite
methods. In other words,
destroyA()
might be called before or after
destroyB()
. The JUnit Team therefore recommends that developers
declare at most one @BeforeSuite
method and at most one
@AfterSuite
method per test class or test interface unless there are no
dependencies between the @BeforeSuite
methods or between the
@AfterSuite
methods.
Composition
@AfterSuite
may be used as a meta-annotation in order to create
a custom composed annotation that inherits the semantics of
@AfterSuite
.
- Since:
- 1.11
- See Also: