Package com.ginsberg.junit.exit
Class SystemExitExtension
java.lang.Object
com.ginsberg.junit.exit.SystemExitExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.BeforeEachCallback,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.TestExecutionExceptionHandler
public class SystemExitExtension
extends Object
implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.TestExecutionExceptionHandler
Entry point for JUnit tests. This class is responsible for installing the preferred `ExitPreventerStrategy`
and interpreting the results.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) voidhandleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable throwable) This is here so we can catch exceptions thrown by the `ExitPreventerStrategy` and prevent them from stopping the annotated test.
-
Constructor Details
-
SystemExitExtension
public SystemExitExtension()
-
-
Method Details
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
-
handleTestExecutionException
public void handleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable throwable) throws Throwable This is here so we can catch exceptions thrown by the `ExitPreventerStrategy` and prevent them from stopping the annotated test. If anything other than our own exception comes through, throw it because the `ExitPreventerStrategy` has encountered some other test-failing exception.- Specified by:
handleTestExecutionExceptionin interfaceorg.junit.jupiter.api.extension.TestExecutionExceptionHandler- Parameters:
context- the current extension context; nevernullthrowable- theThrowableto handle; nevernull- Throws:
Throwable- if the throwable argument is not a SystemExitPreventedException
-