Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log state of test execution result using visual separator #199

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
public class TestVisualSeparatorExtension implements BeforeEachCallback, AfterEachCallback,
BeforeAllCallback, AfterAllCallback {
private final Logger logger = LoggerFactory.getLogger(TestVisualSeparatorExtension.class);
private static final Logger LOGGER = LoggerFactory.getLogger(TestVisualSeparatorExtension.class);

private TestVisualSeparatorExtension() {
// Private constructor to prevent instantiation
Expand All @@ -27,26 +27,31 @@ private TestVisualSeparatorExtension() {
@Override
public void beforeAll(ExtensionContext extensionContext) {
LoggerUtils.logSeparator();
logger.info("TestClass {} STARTED", extensionContext.getRequiredTestClass().getName());
LOGGER.info("TestClass {} STARTED", extensionContext.getRequiredTestClass().getName());
}

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

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

@Override
public void afterEach(ExtensionContext extensionContext) {
logger.info("Test {}.{} FINISHED", extensionContext.getRequiredTestClass().getName(),
extensionContext.getDisplayName().replace("()", ""));
String state = "SUCCEEDED";
if (extensionContext.getExecutionException().isPresent()) {
state = "FAILED";
}

LOGGER.info("Test {}.{} {}", extensionContext.getRequiredTestClass().getName(),
extensionContext.getDisplayName().replace("()", ""), state);
LoggerUtils.logSeparator();
}
}