Event Dispatcher  v0.1.6-beta.1
Project that offers a small library that allows to subscribe and fire events.
TimingExtension

Detailed Description

The TimingExtension class implements the BeforeTestExecutionCallback and the AfterTestExecutionCallback interfaces, which overrides the.

method and the

method.

An Extension can be registered declaratively via org.junit.jupiter.api.extension.ExtendWith, programmatically via {@linkplain org.junit.jupiter.api.extension.RegisterExtension @RegisterExtension}, or automatically via the {@linkplain java.util.ServiceLoader ServiceLoader} mechanism.

See also
beforeTestExecution(ExtensionContext)
afterTestExecution(ExtensionContext)

Definition at line 25 of file TimingExtension.java.

+ Inheritance diagram for TimingExtension:

Public Member Functions

void beforeTestExecution (ExtensionContext context) throws Exception
 
void afterTestExecution (ExtensionContext context) throws Exception
 

Private Member Functions

Store getStore (ExtensionContext context)
 

Static Private Attributes

static final Logger LOGGER = LogManager.getLogger(TimingExtension.class)
 
static final String START_TIME = "start time"
 

Member Function Documentation

◆ beforeTestExecution()

void beforeTestExecution ( ExtensionContext  context) throws Exception

This callback is invoked immediately after each test has been executed, and its only purpose is to start the test timer to measure the elapsed time.

This will store the current system time value for later retrieval under the

key.

Parameters
contextthe current extension context, never
null
See also
BeforeTestExecutionCallback::beforeTestExecution(ExtensionContext)

Definition at line 44 of file TimingExtension.java.

◆ afterTestExecution()

void afterTestExecution ( ExtensionContext  context) throws Exception

This callback is invoked immediately after each test has been executed, and its only purpose is to stop the timer and to log out the test elapsed time.

This method will retrieve the stored value under the

key and calculate the elapsed time.

Parameters
contextthe current extension context, never
null
See also
AfterTestExecutionCallback::afterTestExecution(ExtensionContext)

Definition at line 61 of file TimingExtension.java.

◆ getStore()

Store getStore ( ExtensionContext  context)
private

Returns the.

Store

instance that is associated for the given

ExtensionContext

.

Parameters
contextthe context in which the current test or container is being executed. Extensions are provided an instance of ExtensionContext to perform their work.
Returns
the Store instance that provides methods for extensions to save and retrieve data.

Definition at line 79 of file TimingExtension.java.

Member Data Documentation

◆ LOGGER

final Logger LOGGER = LogManager.getLogger(TimingExtension.class)
staticprivate

Definition at line 27 of file TimingExtension.java.

◆ START_TIME

final String START_TIME = "start time"
staticprivate

Definition at line 29 of file TimingExtension.java.