@Target(value={ANNOTATION_TYPE,METHOD}) @Retention(value=RUNTIME) @Documented @API(status=EXPERIMENTAL, since="5.0") @Testable public @interface TestFactory
@TestFactory
is used to signal that the annotated method is a
test factory method.
In contrast to @Test
methods, a test factory is not itself
a test case but rather a factory for test cases.
@TestFactory
methods must not be private
or static
and must return a Stream
, Collection
, Iterable
, or
Iterator
of DynamicNode
instances. Valid, instantiable
subclasses of DynamicNode
are DynamicContainer
and
DynamicTest
. These DynamicTest
s will then be executed lazily,
enabling dynamic and even non-deterministic generation of test cases.
Any Stream
returned by a @TestFactory
will be properly
closed by calling stream.close()
, making it safe to use a resource
such as Files.lines()
.
@TestFactory
methods may optionally declare parameters to be
resolved by ParameterResolvers
.
Test
,
DynamicNode
,
DynamicTest
,
DynamicContainer