@API(value=Experimental) public abstract class AbstractTestRuleSupport extends Object implements BeforeEachCallback, TestExecutionExceptionHandler, AfterEachCallback
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractTestRuleSupport(Function<RuleAnnotatedMember,AbstractTestRuleAdapter> adapterGenerator,
Class<? extends org.junit.rules.TestRule> ruleType) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterEach(TestExtensionContext context)
Callback that is invoked after each test has been invoked.
|
void |
beforeEach(TestExtensionContext context)
Callback that is invoked before each test is invoked.
|
protected abstract RuleAnnotatedMember |
createRuleAnnotatedMember(TestExtensionContext context,
Member member) |
protected abstract List<Member> |
findRuleAnnotatedMembers(Object testInstance) |
protected Class<org.junit.Rule> |
getAnnotationType() |
protected Class<? extends org.junit.rules.TestRule> |
getRuleType() |
void |
handleTestExecutionException(TestExtensionContext context,
Throwable throwable)
Handle the supplied
throwable. |
protected AbstractTestRuleSupport(Function<RuleAnnotatedMember,AbstractTestRuleAdapter> adapterGenerator, Class<? extends org.junit.rules.TestRule> ruleType)
protected abstract RuleAnnotatedMember createRuleAnnotatedMember(TestExtensionContext context, Member member)
protected abstract List<Member> findRuleAnnotatedMembers(Object testInstance)
protected Class<org.junit.Rule> getAnnotationType()
protected Class<? extends org.junit.rules.TestRule> getRuleType()
public void beforeEach(TestExtensionContext context) throws Exception
BeforeEachCallbackbeforeEach in interface BeforeEachCallbackcontext - the current extension context; never nullExceptionpublic void handleTestExecutionException(TestExtensionContext context, Throwable throwable) throws 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 test
exception in the supplied TestExtensionContext 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 nullThrowablepublic void afterEach(TestExtensionContext context) throws Exception
AfterEachCallbackafterEach in interface AfterEachCallbackcontext - the current extension context; never nullException