Class AbstractAllOrEachExtension
java.lang.Object
com.linecorp.centraldogma.testing.junit.AbstractAllOrEachExtension
- All Implemented Interfaces:
AfterAllCallback
,AfterEachCallback
,BeforeAllCallback
,BeforeEachCallback
,Extension
- Direct Known Subclasses:
CentralDogmaExtension
public abstract class AbstractAllOrEachExtension
extends Object
implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback
A base class for JUnit5 extensions that allows implementations to control whether the callbacks are run
around the entire class, like
BeforeAll
or AfterAll
, or around each test method, like
BeforeEach
or AfterEach
. By default, the extension will run around the entire class -
implementations that want to run around each test method should override runForEachTest()
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
after
(ExtensionContext context) A method that should be run at the end of a test lifecycle.final void
afterAll
(ExtensionContext context) final void
afterEach
(ExtensionContext context) protected abstract void
before
(ExtensionContext context) A method that should be run at the beginning of a test lifecycle.final void
beforeAll
(ExtensionContext context) final void
beforeEach
(ExtensionContext context) protected boolean
Returns whether this extension should run around each test method instead of the entire test class.
-
Constructor Details
-
AbstractAllOrEachExtension
public AbstractAllOrEachExtension()
-
-
Method Details
-
before
A method that should be run at the beginning of a test lifecycle. IfrunForEachTest()
returnsfalse
, this is run once before all tests, otherwise it is run before each test method.- Throws:
Exception
-
after
A method that should be run at the end of a test lifecycle. IfrunForEachTest()
returnsfalse
, this is run once after all tests, otherwise it is run after each test method.- Throws:
Exception
-
beforeAll
- Specified by:
beforeAll
in interfaceBeforeAllCallback
- Throws:
Exception
-
afterAll
- Specified by:
afterAll
in interfaceAfterAllCallback
- Throws:
Exception
-
beforeEach
- Specified by:
beforeEach
in interfaceBeforeEachCallback
- Throws:
Exception
-
afterEach
- Specified by:
afterEach
in interfaceAfterEachCallback
- Throws:
Exception
-
runForEachTest
protected boolean runForEachTest()Returns whether this extension should run around each test method instead of the entire test class. Implementations should override this method to returntrue
to run around each test method.
-