Interface MethodOrderer

    • Field Detail

      • DEFAULT_ORDER_PROPERTY_NAME

        @API(status=STABLE,
             since="5.9")
        static final java.lang.String DEFAULT_ORDER_PROPERTY_NAME
        Property name used to set the default method orderer class name: "junit.jupiter.testmethod.order.default"

        Supported Values

        Supported values include fully qualified class names for types that implement MethodOrderer.

        If not specified, test methods will be ordered using an algorithm that is deterministic but intentionally non-obvious.

        Since:
        5.7
        See Also:
        Constant Field Values
    • Method Detail

      • getDefaultExecutionMode

        default java.util.Optional<ExecutionMode> getDefaultExecutionMode()
        Get the default ExecutionMode for the test class configured with this MethodOrderer.

        This method is guaranteed to be invoked after orderMethods(MethodOrdererContext) which allows implementations of this method to determine the appropriate return value programmatically, potentially based on actions that were taken in orderMethods().

        Defaults to SAME_THREAD, since ordered methods are typically sorted in a fashion that would conflict with concurrent execution.

        In case the ordering does not conflict with concurrent execution, implementations should return an empty Optional to signal that the engine should decide which execution mode to use.

        Can be overridden via an explicit @Execution declaration on the test class or in concrete implementations of the MethodOrderer API.

        Returns:
        the default ExecutionMode; never null but potentially empty
        See Also:
        orderMethods(MethodOrdererContext)