Module org.testfx

Class FxToolkit


  • public final class FxToolkit
    extends Object
    Responsible for setup and cleanup of JavaFX fixtures that need the JavaFX thread.

    Overview

    This class methods cover three different kinds of fixtures:

    1. Container fixtures, which are registered as registeredStage.
    2. Content fixtures, which are attached to the registered registeredStage.
    3. Individual fixtures, which do not require a registeredStage.
    Additionally it keeps an internal context.

    1. Container Fixtures

    They can be registered as registeredStage and provide a top-level container, i.e. Stages.

    The primary stage can be registered as registeredStage using registerPrimaryStage(). This call is mandatory before any other JavaFX fixture can be created.

    Other stages can be registered as registeredStage using registerStage(Supplier<Stage>).

    2. Content Fixtures

    They can be attached to the registeredStage.

    Either constructed by calling an Application.start(), by supplying Scenes, Parents, or by consuming a Stage.

    Use: setupStage(Consumer<Stage>), setupApplication(Class<? extends Application>), setupScene(Supplier<Scene>) or setupSceneRoot(Supplier<Parent>)

    3. Individual Fixtures

    To setup individual Stages, Scenes or Nodes use setupFixture(Runnable) and setupFixture(Callable).

    Internal Context

    Is internally responsible for handle the registered Stage for attachments, handle timeouts, provide the Application for the Toolkit launch and execute the setup in the JavaFX thread. The primary Stage is constructed by the platform.