1 package com.fermod.extension;
3 import java.lang.reflect.Method;
5 import org.apache.logging.log4j.LogManager;
6 import org.apache.logging.log4j.Logger;
7 import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
8 import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
9 import org.junit.jupiter.api.extension.ExtensionContext;
10 import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
11 import org.junit.jupiter.api.extension.ExtensionContext.Store;
25 public class TimingExtension implements BeforeTestExecutionCallback, AfterTestExecutionCallback {
62 Method testMethod = context.getRequiredTestMethod();
64 long duration = System.currentTimeMillis() - startTime;
66 LOGGER.info(String.format(
"Method \"%s\" took %s ms.", testMethod.getName(), duration));
79 private Store
getStore(ExtensionContext context) {
80 return context.getStore(Namespace.create(getClass(), context.getRequiredTestMethod()));
static final Logger LOGGER
void afterTestExecution(ExtensionContext context)
This callback is invoked immediately after each test has been executed, and its only purpose is to st...
void beforeTestExecution(ExtensionContext context)
This callback is invoked immediately after each test has been executed, and its only purpose is to st...
Store getStore(ExtensionContext context)
Returns the.
The TimingExtension class implements the BeforeTestExecutionCallback and the AfterTestExecutionCallba...
static final String START_TIME