File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
documentation/src/docs/asciidoc Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -302,12 +302,15 @@ A `DynamicTest` is a test case generated at runtime.
302302It is composed of a _display name_ and an `Executable`. `Executable` is a `@FunctionalInterface`
303303which means that the implementations of dynamic tests can be provided as _lambda expressions_
304304or _method references_.
305- Note that the execution lifecycle of dynamic tests is quite different than it is for standard `@Test` cases.
306- Specifically, `@BeforeEach` and `@AfterEach` methods and their corresponding extension callbacks
307- are not executed for dynamic tests.
308- The execution of those callbacks would not be useful in most dynamic testing scenarios
309- since variables used in lambdas are bound to instance variables at execution time of the factory method
310- rather than execution time of the lambda itself.
305+
306+ .Dynamic Test Lifecycle
307+ WARNING: The execution lifecycle of a dynamic test is quite different than it is for a
308+ standard `@Test` case. Specifically, there are not any lifecycle callbacks for dynamic
309+ tests. This means that `@BeforeEach` and `@AfterEach` methods and their corresponding
310+ extension callbacks are not executed for dynamic tests. In other words, if you access
311+ fields from the test instance within a lambda expression for a dynamic test, those fields
312+ will not be reset by callback methods or extensions between the execution of dynamic
313+ tests generated by the same `@TestFactory` method.
311314
312315As of JUnit Jupiter {jupiter-version}, dynamic tests must always be created by factory
313316methods; however, this might be complemented by a registration facility in a later
You can’t perform that action at this time.
0 commit comments