Package io.klib.swtbot.jupiter
Class ScreenshotExtension
java.lang.Object
io.klib.swtbot.jupiter.ScreenshotExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler,org.junit.jupiter.api.extension.TestExecutionExceptionHandler
public final class ScreenshotExtension
extends Object
implements org.junit.jupiter.api.extension.TestExecutionExceptionHandler, org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler
Jupiter 5/6 exception handler capturing test and lifecycle failures before rethrowing
the same original throwable. Aborted tests are not captured. Register an instance
with RegisterExtension; static registration covers class lifecycle failures.
Requires a live application Display and shell; does not create UI or a test engine.
-
Constructor Summary
ConstructorsConstructorDescriptionScreenshotExtension(Supplier<Screenshots> screenshots, Supplier<org.eclipse.swt.widgets.Shell> shell) Creates an extension using application-owned capture support. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleAfterAllMethodExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) Captures an after-all failure if application UI remains available.voidhandleAfterEachMethodExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) Captures an after-each failure if application UI remains available.voidhandleBeforeAllMethodExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) Captures a before-all failure, except an aborted test.voidhandleBeforeEachMethodExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) Captures a before-each failure, except an aborted test.voidhandleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) Captures a test-method failure, except an aborted test.
-
Constructor Details
-
ScreenshotExtension
public ScreenshotExtension(Supplier<Screenshots> screenshots, Supplier<org.eclipse.swt.widgets.Shell> shell) Creates an extension using application-owned capture support.- Parameters:
screenshots- non-null supplier evaluated during failure handling; null result skips captureshell- non-null shell supplier evaluated on the application UI thread- Throws:
NullPointerException- if either supplier is null
-
-
Method Details
-
handleTestExecutionException
public void handleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) throws Throwable Captures a test-method failure, except an aborted test.- Specified by:
handleTestExecutionExceptionin interfaceorg.junit.jupiter.api.extension.TestExecutionExceptionHandler- Parameters:
context- current invocation identityoriginal- original failure- Throws:
Throwable- the same original failure, with diagnostic problems suppressed
-
handleBeforeAllMethodExecutionException
public void handleBeforeAllMethodExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) throws Throwable Captures a before-all failure, except an aborted test.- Specified by:
handleBeforeAllMethodExecutionExceptionin interfaceorg.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler- Parameters:
context- current container identityoriginal- original failure- Throws:
Throwable- the same original failure, with diagnostic problems suppressed
-
handleBeforeEachMethodExecutionException
public void handleBeforeEachMethodExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) throws Throwable Captures a before-each failure, except an aborted test.- Specified by:
handleBeforeEachMethodExecutionExceptionin interfaceorg.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler- Parameters:
context- current invocation identityoriginal- original failure- Throws:
Throwable- the same original failure, with diagnostic problems suppressed
-
handleAfterEachMethodExecutionException
public void handleAfterEachMethodExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) throws Throwable Captures an after-each failure if application UI remains available.- Specified by:
handleAfterEachMethodExecutionExceptionin interfaceorg.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler- Parameters:
context- current invocation identityoriginal- original failure- Throws:
Throwable- the same original failure; aborted tests are not captured
-
handleAfterAllMethodExecutionException
public void handleAfterAllMethodExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable original) throws Throwable Captures an after-all failure if application UI remains available.- Specified by:
handleAfterAllMethodExecutionExceptionin interfaceorg.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler- Parameters:
context- current container identityoriginal- original failure- Throws:
Throwable- the same original failure; aborted tests are not captured
-