abstract class AbstractTestRuleSupport<T extends java.lang.reflect.Member> extends java.lang.Object implements BeforeEachCallback, TestExecutionExceptionHandler, AfterEachCallback
| Modifier and Type | Field and Description |
|---|---|
private java.util.function.Function<TestRuleAnnotatedMember,AbstractTestRuleAdapter> |
adapterGenerator |
private java.lang.Class<? extends org.junit.rules.TestRule> |
ruleType |
| Constructor and Description |
|---|
AbstractTestRuleSupport(java.util.function.Function<TestRuleAnnotatedMember,AbstractTestRuleAdapter> adapterGenerator,
java.lang.Class<? extends org.junit.rules.TestRule> ruleType) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterEach(ExtensionContext context)
Callback that is invoked after each test has been invoked.
|
void |
beforeEach(ExtensionContext context)
Callback that is invoked before each test is invoked.
|
protected abstract java.util.List<T> |
findRuleAnnotatedMembers(java.lang.Object testInstance) |
protected java.lang.Class<? extends org.junit.rules.TestRule> |
getRuleType() |
void |
handleTestExecutionException(ExtensionContext context,
java.lang.Throwable throwable)
Handle the supplied
throwable. |
private void |
invokeAppropriateMethodOnRuleAnnotatedMembers(ExtensionContext context,
java.util.function.Consumer<GenericBeforeAndAfterAdvice> methodCaller) |
private final java.lang.Class<? extends org.junit.rules.TestRule> ruleType
private final java.util.function.Function<TestRuleAnnotatedMember,AbstractTestRuleAdapter> adapterGenerator
AbstractTestRuleSupport(java.util.function.Function<TestRuleAnnotatedMember,AbstractTestRuleAdapter> adapterGenerator, java.lang.Class<? extends org.junit.rules.TestRule> ruleType)
protected abstract java.util.List<T> findRuleAnnotatedMembers(java.lang.Object testInstance)
protected java.lang.Class<? extends org.junit.rules.TestRule> getRuleType()
public void beforeEach(ExtensionContext context) throws java.lang.Exception
BeforeEachCallbackbeforeEach in interface BeforeEachCallbackcontext - the current extension context; never nulljava.lang.Exceptionpublic void handleTestExecutionException(ExtensionContext context, java.lang.Throwable throwable) throws java.lang.Throwable
TestExecutionExceptionHandlerthrowable.
Implementors must perform one of the following.
throwable, thereby preventing propagation.throwable as is.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.
handleTestExecutionException in interface TestExecutionExceptionHandlercontext - the current extension context; never nullthrowable - the Throwable to handle; never nulljava.lang.Throwablepublic void afterEach(ExtensionContext context) throws java.lang.Exception
AfterEachCallbackafterEach in interface AfterEachCallbackcontext - the current extension context; never nulljava.lang.Exceptionprivate void invokeAppropriateMethodOnRuleAnnotatedMembers(ExtensionContext context, java.util.function.Consumer<GenericBeforeAndAfterAdvice> methodCaller)