Class ScreenShooter

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    @ParametersAreNonnullByDefault
    public class ScreenShooter
    extends org.junit.rules.TestWatcher
    Usage:
      @Rule
     public ScreenShooter makeScreenshotOnFailure = ScreenShooter.failedTests();
    or
      @Rule
     public ScreenShooter makeScreenshotOnEveryTest = ScreenShooter.failedTests().succeededTests();
    or
      @Rule
     public ScreenShooter makeScreenshotOnEveryTest = ScreenShooter.failedTests().to("test-results/img/");
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void failed​(java.lang.Throwable e, org.junit.runner.Description description)  
      static ScreenShooter failedTests()  
      protected void finished​(org.junit.runner.Description description)  
      protected void starting​(org.junit.runner.Description test)  
      protected void succeeded​(org.junit.runner.Description test)  
      ScreenShooter succeededTests()  
      ScreenShooter to​(java.lang.String folderWithScreenshots)
      One-liner to configure Configuration.reportsFolder property
      • Methods inherited from class org.junit.rules.TestWatcher

        apply, skipped, skipped
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • captureSuccessfulTests

        public boolean captureSuccessfulTests
    • Method Detail

      • failedTests

        @CheckReturnValue
        @Nonnull
        public static ScreenShooter failedTests()
      • succeededTests

        @Nonnull
        public ScreenShooter succeededTests()
      • starting

        protected void starting​(org.junit.runner.Description test)
        Overrides:
        starting in class org.junit.rules.TestWatcher
      • succeeded

        protected void succeeded​(org.junit.runner.Description test)
        Overrides:
        succeeded in class org.junit.rules.TestWatcher
      • failed

        protected void failed​(java.lang.Throwable e,
                              org.junit.runner.Description description)
        Overrides:
        failed in class org.junit.rules.TestWatcher
      • finished

        protected void finished​(org.junit.runner.Description description)
        Overrides:
        finished in class org.junit.rules.TestWatcher
      • to

        @Nonnull
        public ScreenShooter to​(java.lang.String folderWithScreenshots)
        One-liner to configure Configuration.reportsFolder property
        Parameters:
        folderWithScreenshots - Folder to put screenshots to