Class TestRuleSupport

    • Method Detail

      • findRuleAnnotatedMembers

        private java.util.List<TestRuleAnnotatedMember> findRuleAnnotatedMembers​(java.lang.Object testInstance)
        See Also:
        BlockJUnit4ClassRunner.withRules(org.junit.runners.model.FrameworkMethod, java.lang.Object, org.junit.runners.model.Statement), RunRules
      • findAnnotatedMethods

        private java.util.List<java.lang.reflect.Method> findAnnotatedMethods​(java.lang.Object testInstance)
      • findAnnotatedFields

        private java.util.List<java.lang.reflect.Field> findAnnotatedFields​(java.lang.Object testInstance)
      • handleTestExecutionException

        public void handleTestExecutionException​(ExtensionContext context,
                                                 java.lang.Throwable throwable)
                                          throws java.lang.Throwable
        Description copied from interface: TestExecutionExceptionHandler
        Handle the supplied throwable.

        Implementors must perform one of the following.

        1. Swallow the supplied throwable, thereby preventing propagation.
        2. Rethrow the supplied throwable as is.
        3. Throw a new exception, potentially wrapping the supplied throwable.

        If the supplied throwable is swallowed, subsequent TestExecutionExceptionHandlers will not be invoked; otherwise, the next registered TestExecutionExceptionHandler (if there is one) will be invoked with any Throwable thrown by this handler.

        Note that the execution exception in the supplied ExtensionContext will not contain the Throwable thrown during invocation of the corresponding @Test method.

        Specified by:
        handleTestExecutionException in interface TestExecutionExceptionHandler
        Parameters:
        context - the current extension context; never null
        throwable - the Throwable to handle; never null
        Throws:
        java.lang.Throwable
      • afterEach

        public void afterEach​(ExtensionContext context)
        Description copied from interface: AfterEachCallback
        Callback that is invoked after each test has been invoked.
        Specified by:
        afterEach in interface AfterEachCallback
        Parameters:
        context - the current extension context; never null
      • invokeAppropriateMethodOnRuleAnnotatedMembers

        private long invokeAppropriateMethodOnRuleAnnotatedMembers​(ExtensionContext context,
                                                                   java.util.function.Consumer<java.util.List<TestRuleAnnotatedMember>> ordering,
                                                                   java.util.function.Consumer<GenericBeforeAndAfterAdvice> methodCaller)
        Returns:
        the number of appropriate rule-annotated members that were discovered