-
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.
Add kubernetes and junit5 tweaks for faster and easier testing (#24)
- Loading branch information
Showing
5 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
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
53 changes: 53 additions & 0 deletions
53
src/main/java/io/odh/test/framework/TestExceptionCallbackListener.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,53 @@ | ||
/* | ||
* 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 org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler; | ||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* jUnit5 specific class which listening on test exception callbacks | ||
*/ | ||
public class TestExceptionCallbackListener implements TestExecutionExceptionHandler, LifecycleMethodExecutionExceptionHandler { | ||
static final Logger LOGGER = LoggerFactory.getLogger(TestExceptionCallbackListener.class); | ||
|
||
@Override | ||
public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable { | ||
LOGGER.error("Test failed at {} : {}", "Test execution", throwable.getMessage(), throwable); | ||
//TODO collect proper logs | ||
throw throwable; | ||
} | ||
|
||
@Override | ||
public void handleBeforeAllMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable { | ||
LOGGER.error("Test failed at {} : {}", "Test before all", throwable.getMessage(), throwable); | ||
//TODO collect proper logs | ||
throw throwable; | ||
} | ||
|
||
@Override | ||
public void handleBeforeEachMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable { | ||
LOGGER.error("Test failed at {} : {}", "Test before each", throwable.getMessage(), throwable); | ||
//TODO collect proper logs | ||
throw throwable; | ||
} | ||
|
||
@Override | ||
public void handleAfterEachMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable { | ||
LOGGER.error("Test failed at {} : {}", "Test after each", throwable.getMessage(), throwable); | ||
//TODO collect proper logs | ||
throw throwable; | ||
} | ||
|
||
@Override | ||
public void handleAfterAllMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable { | ||
LOGGER.error("Test failed at {} : {}", "Test after all", throwable.getMessage(), throwable); | ||
//TODO collect proper logs | ||
throw throwable; | ||
} | ||
} |
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