Annotation Type TestFactory

    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. 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 calling stream.close(), making it safe to use a resource such as Files.lines() as the initial source of the stream.

    @TestFactory methods may optionally declare parameters to be resolved by ParameterResolvers.

    See Also:
    Test, DynamicNode, DynamicTest, DynamicContainer