Skip to content

Commit

Permalink
Add info into TVS about TestClass started/finished (#170)
Browse files Browse the repository at this point in the history
## Description

Added aslo separation on test class level to see thich beforeall and
afterall is for what class.


## Type of Change

Please delete options that are not relevant.

* New feature (non-breaking change which adds functionality)

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit/integration tests pass locally with my
changes

Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys authored Aug 20, 2024
1 parent 5c419b3 commit 6ee3bc8
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 6ee3bc8

Please sign in to comment.