@API(status=EXPERIMENTAL,
since="5.0")
public class ExternalResourceSupport
extends java.lang.Object
implements BeforeEachCallback, AfterEachCallback
Extension provides native support for subclasses of
the ExternalResource rule from JUnit 4.
@Rule-annotated fields as well as methods are supported.
By using this class-level extension on a test class such
ExternalResource implementations in legacy code bases
can be left unchanged including the JUnit 4 rule import statements.
However, if you intend to develop a new extension for JUnit 5 please use the new extension model of JUnit Jupiter instead of the rule-based model of JUnit 4.
ExternalResource,
TestRule,
Rule| Modifier and Type | Field and Description |
|---|---|
private TestRuleSupport |
support |
| Constructor and Description |
|---|
ExternalResourceSupport() |
| 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.
|
private final TestRuleSupport support
public void beforeEach(ExtensionContext context) throws java.lang.Exception
BeforeEachCallbackbeforeEach in interface BeforeEachCallbackcontext - the current extension context; never nulljava.lang.Exceptionpublic void afterEach(ExtensionContext context) throws java.lang.Exception
AfterEachCallbackafterEach in interface AfterEachCallbackcontext - the current extension context; never nulljava.lang.Exception