Class ScreenshotRule

java.lang.Object
org.junit.rules.TestWatcher
io.klib.swtbot.junit4.ScreenshotRule
All Implemented Interfaces:
org.junit.rules.TestRule

public final class ScreenshotRule extends org.junit.rules.TestWatcher
JUnit 4 failure screenshots without replacing the original test failure. TestWatcher runs after ordinary teardown; retain UI or use Screenshots.guard(String, Supplier, Screenshots.Action) for early evidence.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScreenshotRule(Supplier<Screenshots> screenshots, Supplier<org.eclipse.swt.widgets.Shell> shell)
    Creates a rule using application-owned screenshot support and shell.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    failed(Throwable original, org.junit.runner.Description description)
    Captures a failed test after cleanup, attaching diagnostic errors as suppressed.

    Methods inherited from class org.junit.rules.TestWatcher

    apply, finished, skipped, skipped, starting, succeeded

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ScreenshotRule

      public ScreenshotRule(Supplier<Screenshots> screenshots, Supplier<org.eclipse.swt.widgets.Shell> shell)
      Creates a rule using application-owned screenshot support and shell.
      Parameters:
      screenshots - non-null supplier evaluated during failure handling; null result skips capture
      shell - non-null shell supplier evaluated on the application UI thread
      Throws:
      NullPointerException - if either supplier is null
  • Method Details

    • failed

      protected void failed(Throwable original, org.junit.runner.Description description)
      Captures a failed test after cleanup, attaching diagnostic errors as suppressed.
      Overrides:
      failed in class org.junit.rules.TestWatcher
      Parameters:
      original - test failure, never replaced by capture errors
      description - failed test identity used in the artifact label