@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
BeforeEachCallback
beforeEach
in interface BeforeEachCallback
context
- the current extension context; never null
Exception
public void handleTestExecutionException(TestExtensionContext context, Throwable throwable) throws 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 test
exception
in the supplied TestExtensionContext
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
Throwable
public void afterEach(TestExtensionContext context) throws Exception
AfterEachCallback
afterEach
in interface AfterEachCallback
context
- the current extension context; never null
Exception