Skip to content

Commit

Permalink
Add info into TVS about TestClass started/finished
Browse files Browse the repository at this point in the history
Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys committed Aug 20, 2024
1 parent 5c419b3 commit 691030e
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
package io.skodjob.testframe.listeners;

import io.skodjob.testframe.utils.LoggerUtils;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
Expand All @@ -14,23 +16,36 @@
/**
* jUnit5 specific class which listening on test callbacks
*/
public class TestVisualSeparatorExtension implements BeforeEachCallback, AfterEachCallback {
public class TestVisualSeparatorExtension implements BeforeEachCallback, AfterEachCallback,
BeforeAllCallback, AfterAllCallback {
private final Logger logger = LoggerFactory.getLogger(TestVisualSeparatorExtension.class);

private TestVisualSeparatorExtension() {
// Private constructor to prevent instantiation
}

@Override
public void beforeAll(ExtensionContext extensionContext) {
LoggerUtils.logSeparator();
logger.info("TestClass {} STARTED", extensionContext.getRequiredTestClass().getName());
}

@Override
public void afterAll(ExtensionContext extensionContext) {
logger.info("TestClass {} FINISHED", extensionContext.getRequiredTestClass().getName());
LoggerUtils.logSeparator();
}

@Override
public void beforeEach(ExtensionContext extensionContext) {
LoggerUtils.logSeparator();
logger.info("{}.{}-STARTED", extensionContext.getRequiredTestClass().getName(),
logger.info("Test {}.{} STARTED", extensionContext.getRequiredTestClass().getName(),
extensionContext.getDisplayName().replace("()", ""));
}

@Override
public void afterEach(ExtensionContext extensionContext) {
logger.info("{}.{}-FINISHED", extensionContext.getRequiredTestClass().getName(),
logger.info("Test {}.{} FINISHED", extensionContext.getRequiredTestClass().getName(),
extensionContext.getDisplayName().replace("()", ""));
LoggerUtils.logSeparator();
}
Expand Down

0 comments on commit 691030e

Please sign in to comment.