Class DynamicTest

    • Method Detail

      • dynamicTest

        public static DynamicTest dynamicTest​(String displayName,
                                              Executable executable)
        Factory for creating a new DynamicTest for the supplied display name and executable code block.
        Parameters:
        displayName - the display name for the dynamic test; never null or blank
        executable - the executable code block for the dynamic test; never null
        See Also:
        stream(Iterator, Function, ThrowingConsumer)
      • dynamicTest

        public static DynamicTest dynamicTest​(String displayName,
                                              URI testSourceUri,
                                              Executable executable)
        Factory for creating a new DynamicTest for the supplied display name, custom test source URI, and executable code block.
        Parameters:
        displayName - the display name for the dynamic test; never null or blank
        testSourceUri - a custom test source URI for the dynamic test; may be null if the framework should generate the test source based on the @TestFactory method
        executable - the executable code block for the dynamic test; never null
        Since:
        5.3
        See Also:
        stream(Iterator, Function, ThrowingConsumer)
      • stream

        public static <T> Stream<DynamicTest> stream​(Iterator<T> inputGenerator,
                                                     Function<? super T,String> displayNameGenerator,
                                                     ThrowingConsumer<? super T> testExecutor)
        Generate a stream of dynamic tests based on the supplied generators and test executor.

        Use this method when the set of dynamic tests is nondeterministic in nature.

        The supplied inputGenerator is responsible for generating input values. A DynamicTest will be added to the resulting stream for each dynamically generated input value, using the supplied displayNameGenerator and testExecutor.

        Type Parameters:
        T - the type of input generated by the inputGenerator and used by the displayNameGenerator and testExecutor
        Parameters:
        inputGenerator - an Iterator that serves as a dynamic input generator; never null
        displayNameGenerator - a function that generates a display name based on an input value; never null
        testExecutor - a consumer that executes a test based on an input value; never null
        Returns:
        a stream of dynamic tests based on the supplied generators and executor; never null
        See Also:
        dynamicTest(String, Executable)
      • getExecutable

        public Executable getExecutable()
        Get the executable code block associated with this DynamicTest.