Questions tagged [testfx]

Simple and clean testing for JavaFX.

Simple and clean testing for JavaFX.

Features:

  • A fluent and clean API.
  • Flexible setup and cleanup of JavaFX test fixtures.
  • Simple robots to simulate user interactions.
  • Rich collection of matchers to verify expected states.

Support for:

  • Java 8 features and JavaFX 8 controls.
  • JUnit testing framework and Hamcrest matchers.
  • Precise screenshots of failed tests.
  • Headless testing using Monocle.

Sample:

 public class DesktopPaneTest extends ApplicationTest {
    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new DesktopPane(), 800, 600);
        stage.setScene(scene);
        stage.show();
    }

    @Test
    public void should_drag_file_into_trashcan() {
        // given:
        rightClickOn("#desktop").moveTo("New").clickOn("Text Document");
        write("myTextfile.txt").push(ENTER);

        // when:
        drag(".file").dropTo("#trash-can");

        // then:
        verifyThat("#desktop", hasChildren(0, ".file"));
    }
 }

As you can see above, TestFX is emulating GUI action with simple methods like drag(String) or write(String). You are able to call the JavaFX-Components directly via the CSS-ID or CSS-Class string. To call the id you have to add a # before the id, to reach the class you need a . before the classname.

Links:

108 questions
-1
votes
1 answer

Application vs ApplicationTest: different event dispatch?

Currently I'm digging into issues with TextField and default/cancel button. While testing a presumed fix with TestFX, I ran into a difference in event dispatch (?) that make the test fail while the application appears to be working. Below is a very…
kleopatra
  • 51,061
  • 28
  • 99
  • 211
-1
votes
1 answer

TestFX working with popup

I have a scene in JavaFX in which there is a CustomTextField with an autocomplete function. When user is typing a popup is opened with more columns. I have done an automatic scenario in TestFX witch is typing in the CustomTextField. Is there any way…
Trica
  • 53
  • 6
-2
votes
1 answer

Unrecognized Option (vmArgs Java in VSCode)

I'm trying run package org.testfx in my JavaFX application, but i'm a facing error "JavaFX.graphics is not accessible". So I'm trying put vmArgs in VsCode tests to exports javafx.graphics, but not sucessfuly, one help? My…
kauan
  • 15
  • 3
1 2 3 4 5 6 7
8