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
vote
1 answer

Using Jubula jars in JavaFX

I have to develop a program (like squish / jubula / zaptest ) test applications that programmed with JavaFX. So my questions are: 1) Can jubula jars be added to an application as a test framework libraries (like TestFX) ? And if so, is there a…
user4887078
1
vote
1 answer

How do I install TestFX?

I'd like to put together a set of jUnit tests under Eclipse (Neon) on Windows to automate the testing of JavaFX GUIs. It seems that TestFX is the bee's knees for this kind of thing, but having looked around the internet quite a bit, I'm still not…
Lawrence
  • 352
  • 4
  • 14
1
vote
2 answers

TestFX 4 Selecting a value from ChoiceBox / Menu

I'm scratching my head here trying to get my TestFX robot to click on a Menu and then a MenuItem. None of the above classes derive from Node so I cannot use fxRobot.clickOn(Node node). Does anyone else have an idea of how to accomplish this? Besides…
Robin Jonsson
  • 2,761
  • 3
  • 22
  • 42
1
vote
1 answer

testfx isn't printing to stdout

I have a simple application where, if the user clicks the login button, a messages is printed to stdout. I'm trying to start using testfx, but when it simulates the button click, no message is printed. Is this expected behaviour, or is there…
chenshuiluke
  • 319
  • 1
  • 16
1
vote
1 answer

Is TestFX only compatible with FXML?

I am new to TestFX. I am wondering is TestFX only compatible with FXML? I can't find any information related on how to test UI without FXML using TestFX, if it is possible to test without FXML is it possible to share any information or give me a…
blackhazelnut
  • 60
  • 1
  • 9
1
vote
1 answer

Verifying the text of a comboBox

I am using https://github.com/TestFX/TestFX for gui tests of a javafx client. With a testfx query I get the comboBox but I cannot get its text for verification. The comboBox displays enum values whose text is resolved by a converter and a given…
Konter
  • 11
  • 3
1
vote
0 answers

TestFX cannot localize node during Travis CI build after tested application was opened another window

I am working on simple java standalone application with GUI created with JavaFX 8. I wrote some tests of GUI with TestFX framework (version 3.1.0). On my local machine tests works fine, but they are failed on Travis CI environment. Please take a…
It'sMe
  • 125
  • 1
  • 15
1
vote
1 answer

Testing Two Scenes with JemmyFX or TestFX

I have a scene (scene1) that has a button. When I click on the button, the scene changes to scene2. scene2 also has a button. When I click it the scene changes to scene 1. How do I test this behavior in JavaFX2 using JemmyFX or TestFX?
damat-perdigannat
  • 5,780
  • 1
  • 17
  • 33
0
votes
0 answers

FXMLLoader.load(getClass().getResource()) gives null

I'm trying to make tests using TestFX. But when calling this code I get an error. @ExtendWith(ApplicationExtension.class) class HelloApplicationTest extends ApplicationTest { public double x, y; @Start @Override public void…
Kola
  • 1
  • 1
0
votes
0 answers

How can I use two test methods in single Test Class for JavaFx UI testing?

I am currently facing an exception while loading the UI controller. Have written two separate methods for testing client requests for a server while loading files. I have start methods which loads UI controller- @Override public void start(Stage…
0
votes
0 answers

mvn clean install: failed to execute goal org.apache.maven.plugins:maven-compiler plugin:3.8.1 using intellij

when i'm running my code from intellij, it works fine, but when i'm using mvn clean install, these errors appear: i'm using java 18. I don't know what is wrong, I tried to add all dependencies and modules in the project structure, but it does not…
Ina Maria
  • 31
  • 4
0
votes
1 answer

ExceptionInInitializerError with TestFX and Junit5

I am just getting familiar with Java and JavaFX, and am working on a simple project that tests a JavaFX UI. However, I don't think that I'm initializing the tests correctly, as I'm getting an ExceptionInInitializerError when I instantiate the app…
0
votes
2 answers

TestFX setup on Gradle using JUnit 5

I'm working to get TestFX setup for use on a Gradle project. I followed the directions on https://github.com/TestFX/TestFX/blob/master/README.md but it still seems to give me problems. Any ideas why it isn't finding the method? * What went wrong: A…
0
votes
0 answers

Using Awaitility in Testfx FxRobot framework - wait is not happening till node visible

Using Awaitility in Testfx FxRobot framework - Unable to wait till node visible Everytime when fxid element is not shown on UI polling is not happening it is throwing node not found. Another thing is to save the captured snapshot path I am not…
Nee
  • 11
  • 3
0
votes
0 answers

Are there alternatives to javafx.fxml.Initializable to run code at the start of a scene?

The main goal is to run code when the scene is loaded and I know Initializable is the recommended solution and I've been using it except the problem I'm running into is that it's not conducive to integration testing. The logic in my initialize…
notacorn
  • 3,526
  • 4
  • 30
  • 60