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.