Package org.junit.jupiter.api
Annotation Type TestFactory
-
@Target({ANNOTATION_TYPE,METHOD}) @Retention(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 beprivate
orstatic
and must return aStream
,Collection
,Iterable
, orIterator
ofDynamicNode
instances. Valid, instantiable subclasses ofDynamicNode
areDynamicContainer
andDynamicTest
. Dynamic tests 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 callingstream.close()
, making it safe to use a resource such asFiles.lines()
as the initial source of the stream.@TestFactory
methods may optionally declare parameters to be resolved byParameterResolvers
.- Since:
- 5.0
- See Also:
Test
,DynamicNode
,DynamicTest
,DynamicContainer