@@ -320,14 +320,13 @@ For a concrete example, consult the source code for the `{MockitoExtension}` and
320
320
`{ParameterResolver}` defines the `Extension` API for dynamically resolving parameters at
321
321
runtime.
322
322
323
- If a test constructor or a `@Test`, `@RepeatedTest`, `@ParameterizedTest`,
324
- `@TestFactory`, `@BeforeEach`, `@AfterEach`, `@BeforeAll`, or `@AfterAll` method accepts
325
- a parameter, the parameter must be _resolved_ at runtime by a `ParameterResolver`. A
326
- `ParameterResolver` can either be built-in (see `{TestInfoParameterResolver}`) or
327
- <<extensions-registration,registered by the user>>. Generally speaking, parameters may be
328
- resolved by _name_, _type_, _annotation_, or any combination thereof. For concrete
329
- examples, consult the source code for `{CustomTypeParameterResolver}` and
330
- `{CustomAnnotationParameterResolver}`.
323
+ If a _test class_ constructor, _test method_, or _lifecycle method_ (see
324
+ <<writing-tests-classes-and-methods>>) accepts a parameter, the parameter must be
325
+ _resolved_ at runtime by a `ParameterResolver`. A `ParameterResolver` can either be
326
+ built-in (see `{TestInfoParameterResolver}`) or <<extensions-registration,registered by
327
+ the user>>. Generally speaking, parameters may be resolved by _name_, _type_,
328
+ _annotation_, or any combination thereof. For concrete examples, consult the source code
329
+ for `{CustomTypeParameterResolver}` and `{CustomAnnotationParameterResolver}`.
331
330
332
331
[WARNING]
333
332
====
@@ -358,8 +357,10 @@ information for the following events.
358
357
* `testAborted`: invoked after a _test method_ has been aborted
359
358
* `testFailed`: invoked after a _test method_ has failed
360
359
361
- NOTE: In this context, _test method_ refers to any `@Test` method or `@TestTemplate`
362
- method (for example, a `@RepeatedTest` or `@ParameterizedTest`).
360
+ NOTE: In contrast to the definition of "test method" presented in
361
+ <<writing-tests-classes-and-methods>>, in this context _test method_ refers to any
362
+ `@Test` method or `@TestTemplate` method (for example, a `@RepeatedTest` or
363
+ `@ParameterizedTest`).
363
364
364
365
Extensions implementing this interface can be registered at the method level or at the
365
366
class level. In the latter case they will be invoked for any contained _test method_
@@ -551,12 +552,15 @@ details.
551
552
=== Relative Execution Order of User Code and Extensions
552
553
553
554
When executing a test class that contains one or more test methods, a number of extension
554
- callbacks are called in addition to the user-supplied test and lifecycle methods. The
555
- following diagram illustrates the relative order of user-supplied code and extension code.
555
+ callbacks are called in addition to the user-supplied test and lifecycle methods.
556
556
557
+ NOTE: See also: <<writing-tests-test-execution-order>>
558
+
559
+ [[extensions-execution-order-overview]]
557
560
==== User and Extension Code
558
561
559
- User-supplied test and lifecycle methods are shown in orange, with callback code
562
+ The following diagram illustrates the relative order of user-supplied code and extension
563
+ code. User-supplied test and lifecycle methods are shown in orange, with callback code
560
564
implemented by extensions shown in blue. The grey box denotes the execution of a single
561
565
test method and will be repeated for every test method in the test class.
562
566
@@ -627,7 +631,7 @@ steps are optional depending on the presence of user code or extension support f
627
631
corresponding lifecycle callback. For further details on the various lifecycle callbacks
628
632
please consult the respective Javadoc for each annotation and extension.
629
633
630
- [[extensions-lifecycle -wrapping-behavior]]
634
+ [[extensions-execution-order -wrapping-behavior]]
631
635
==== Wrapping Behavior of Callbacks
632
636
633
637
JUnit Jupiter always guarantees _wrapping_ behavior for multiple registered extensions
@@ -644,8 +648,7 @@ callbacks implemented by `Extension2`. `Extension1` is therefore said to _wrap_
644
648
`Extension2`.
645
649
646
650
JUnit Jupiter also guarantees _wrapping_ behavior within class and interface hierarchies
647
- for user-supplied lifecycle callbacks such as `@BeforeAll`, `@AfterAll`, `@BeforeEach`,
648
- and `@AfterEach` methods.
651
+ for user-supplied _lifecycle methods_ (see <<writing-tests-classes-and-methods>>).
649
652
650
653
* `@BeforeAll` methods are inherited from superclasses as long as they are not _hidden_ or
651
654
_overridden_. Furthermore, `@BeforeAll` methods from superclasses will be executed
@@ -786,7 +789,10 @@ See corresponding *.txt file in images folder for the source.
786
789
////
787
790
image::extensions_BrokenLifecycleMethodConfigDemo.png[caption='',title='BrokenLifecycleMethodConfigDemo']
788
791
792
+ [TIP]
793
+ ====
789
794
Due to the aforementioned behavior, the JUnit Team recommends that developers declare at
790
- most one of each type of lifecycle method (i.e., `@BeforeAll`, `@AfterAll`, `@BeforeEach`,
791
- `@AfterEach`) per test class or test interface unless there are no dependencies between
792
- such lifecycle methods.
795
+ most one of each type of _lifecycle method_ (see <<writing-tests-classes-and-methods>>)
796
+ per test class or test interface unless there are no dependencies between such lifecycle
797
+ methods.
798
+ ====
0 commit comments