Annotation Type BeforeSuite
-
@Target(METHOD) @Retention(RUNTIME) @Documented @API(status=MAINTAINED, since="1.13.3") public @interface BeforeSuite@BeforeSuiteis used to signal that the annotated method should be executed before all tests in the current test suite.Method Signatures
@BeforeSuitemethods must have avoidreturn type, must bestaticand must not beprivate.Inheritance and Execution Order
@BeforeSuitemethods are inherited from superclasses as long as they are not overridden according to the visibility rules of the Java language. Furthermore,@BeforeSuitemethods from superclasses will be executed before@BeforeSuitemethods in subclasses.The JUnit Platform Suite Engine does not guarantee the execution order of multiple
@BeforeSuitemethods 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,
@BeforeSuitemethods are in no way linked to@AfterSuitemethods. Consequently, there are no guarantees with regard to their wrapping behavior. For example, given two@BeforeSuitemethodscreateA()andcreateB()as well as two@AfterSuitemethodsdestroyA()anddestroyB(), the order in which the@BeforeSuitemethods are executed (e.g.createA()beforecreateB()) does not imply any order for the seemingly corresponding@AfterSuitemethods. In other words,destroyA()might be called before or afterdestroyB(). The JUnit Team therefore recommends that developers declare at most one@BeforeSuitemethod and at most one@AfterSuitemethod per test class or test interface unless there are no dependencies between the@BeforeSuitemethods or between the@AfterSuitemethods.Composition
@BeforeSuitemay be used as a meta-annotation in order to create a custom composed annotation that inherits the semantics of@BeforeSuite.- Since:
- 1.11
- See Also:
AfterSuite,Suite