From 691030eea9c406835d476bb28f641258d6367bd5 Mon Sep 17 00:00:00 2001 From: David Kornel Date: Tue, 20 Aug 2024 11:39:38 +0200 Subject: [PATCH] Add info into TVS about TestClass started/finished Signed-off-by: David Kornel --- .../TestVisualSeparatorExtension.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/listeners/TestVisualSeparatorExtension.java b/test-frame-common/src/main/java/io/skodjob/testframe/listeners/TestVisualSeparatorExtension.java index 383de14..4d699e9 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/listeners/TestVisualSeparatorExtension.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/listeners/TestVisualSeparatorExtension.java @@ -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; @@ -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(); }