-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use two resoruce stack for class wide and test resources (#27)
- Loading branch information
Showing
9 changed files
with
123 additions
and
62 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/main/java/io/odh/test/framework/TestCallbackListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Skodjob authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.odh.test.framework; | ||
|
||
import io.odh.test.framework.manager.ResourceManager; | ||
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; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Collections; | ||
|
||
/** | ||
* jUnit5 specific class which listening on test callbacks | ||
*/ | ||
public class TestCallbackListener implements BeforeAllCallback, BeforeEachCallback, AfterAllCallback, AfterEachCallback { | ||
|
||
static final Logger LOGGER = LoggerFactory.getLogger(TestCallbackListener.class); | ||
|
||
static final String SEPARATOR_CHAR = "#"; | ||
|
||
@Override | ||
public void beforeAll(ExtensionContext extensionContext) throws Exception { | ||
ResourceManager.getInstance().switchToClassResourceStack(); | ||
} | ||
|
||
@Override | ||
public void beforeEach(ExtensionContext extensionContext) throws Exception { | ||
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR))); | ||
LOGGER.info(String.format("%s.%s-STARTED", extensionContext.getRequiredTestClass().getName(), | ||
extensionContext.getDisplayName().replace("()", ""))); | ||
ResourceManager.getInstance().switchToTestResourceStack(); | ||
} | ||
|
||
@Override | ||
public void afterAll(ExtensionContext extensionContext) throws Exception { | ||
ResourceManager.getInstance().switchToClassResourceStack(); | ||
ResourceManager.getInstance().deleteResources(); | ||
} | ||
|
||
@Override | ||
public void afterEach(ExtensionContext extensionContext) throws Exception { | ||
LOGGER.info(String.format("%s.%s-FINISHED", extensionContext.getRequiredTestClass().getName(), | ||
extensionContext.getDisplayName().replace("()", ""))); | ||
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR))); | ||
ResourceManager.getInstance().switchToTestResourceStack(); | ||
ResourceManager.getInstance().deleteResources(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
io.odh.test.framework.ExecutionListener | ||
io.odh.test.framework.TestPlanExecutionListener |