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
BeforeEachCallback
beforeEach
in interface BeforeEachCallback
context
- the current extension context; never null
java.lang.Exception
public void handleTestExecutionException(ExtensionContext context, java.lang.Throwable throwable) throws java.lang.Throwable
TestExecutionExceptionHandler
throwable
.
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 TestExecutionExceptionHandler
context
- the current extension context; never null
throwable
- the Throwable
to handle; never null
java.lang.Throwable
public void afterEach(ExtensionContext context) throws java.lang.Exception
AfterEachCallback
afterEach
in interface AfterEachCallback
context
- the current extension context; never null
java.lang.Exception
private void invokeAppropriateMethodOnRuleAnnotatedMembers(ExtensionContext context, java.util.function.Consumer<GenericBeforeAndAfterAdvice> methodCaller)