Class TestFXRule

java.lang.Object
org.junit.rules.TestWatcher
org.testfx.framework.junit.TestFXRule
All Implemented Interfaces:
org.junit.rules.TestRule

public class TestFXRule extends org.junit.rules.TestWatcher
Optional JUnit rule that can be used to ensure the JavaFX platform has been initialized before UI tests are run. The rule can also be used for retrying flaky tests.

The rule can be used by adding a @Rule annotated field to your test class:

 public class MyTest extends ApplicationTest {
    @Rule public TestFXRule testFXRule = new TestFXRule();

    @Test
     public void myTest() {
         // ...
     }
 }
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private Throwable[]
     
    private boolean
     
    private final int
     
    private static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    TestFXRule(int retryCount)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.junit.runners.model.Statement
    apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
     
    protected void
    starting(org.junit.runner.Description description)
     

    Methods inherited from class org.junit.rules.TestWatcher

    failed, finished, skipped, skipped, succeeded

    Methods inherited from class java.lang.Object

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

    • retryCount

      private final int retryCount
    • WAIT_MILLIS

      private static final long WAIT_MILLIS
      See Also:
    • initialized

      private boolean initialized
    • currentAttempt

      private int currentAttempt
    • errors

      private Throwable[] errors
  • Constructor Details

    • TestFXRule

      public TestFXRule()
    • TestFXRule

      public TestFXRule(int retryCount)
  • Method Details

    • apply

      public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
      Specified by:
      apply in interface org.junit.rules.TestRule
      Overrides:
      apply in class org.junit.rules.TestWatcher
    • starting

      protected void starting(org.junit.runner.Description description)
      Overrides:
      starting in class org.junit.rules.TestWatcher