Class InteractiveTest

java.lang.Object
com.diffplug.common.swt.InteractiveTest

public class InteractiveTest extends Object
InteractiveTest opens a Coat or Shell, and displays instructions for a human tester to determine whether the test passed or failed. This makes it extremely easy to create and specify a UI test, which can be converted into an automated UI test at a later date.

If the system property `com.diffplug.InteractiveTest.autoclose.milliseconds` is set, then the tests will open and then automatically pass after the specified timeout. This lets a headless CI server ensure that the tests are in working order, although a meatbag is still required for full validation.

  • Field Details

    • AUTOCLOSE_KEY

      public static final String AUTOCLOSE_KEY
      Key for specifying that autoclose should be used.
      See Also:
    • DEFAULT_COLS

      public static final int DEFAULT_COLS
      Default width of testCoat().
      See Also:
    • DEFAULT_ROWS

      public static final int DEFAULT_ROWS
      Default height of testCoat().
      See Also:
  • Method Details

    • testCoat

      public static void testCoat(String instructions, com.diffplug.common.swt.Coat coat)
      Parameters:
      instructions - Instructions for the user to follow.
      coat - A function to populate the test composite.
    • testCoat

      public static void testCoat(String instructions, int cols, int rows, com.diffplug.common.swt.Coat coat)
      Parameters:
      instructions - Instructions for the user to follow.
      cols - Width of the test composite (in multiples of the system font height).
      rows - Height of the test composite (in multiples of the system font height).
      coat - A function to populate the test composite.
    • testCoat

      public static void testCoat(String instructions, @Nullable Point size, com.diffplug.common.swt.Coat coat)
      Parameters:
      instructions - Instructions for the user to follow.
      size - Width and height of the test composite (in multiples of the system font height).
      coat - A function to populate the test composite.
    • testShell

      public static void testShell(String instructions, Function<Display,Shell> harness)
      Parameters:
      instructions - Instructions for the user to follow.
      harness - A function which takes a Display and returns a Shell to test.
    • closeAndPass

      public static void closeAndPass(Control ctl)
      Closes the test for the given control, and passes.
    • closeAndFail

      public static void closeAndFail(Control ctl, Throwable e)
      Closes the test for the given control, and fails.
    • testShellWithoutHandle

      public static void testShellWithoutHandle(String instructions, Consumer<Display> harness)
      Same as testShell, but for situations where it is impossible to return the shell handle.
      Parameters:
      instructions - Instructions for the user to follow.
      harness - A function which takes a Display and returns a Shell to test. The instructions will pop-up next to the test shell.