Repository navigation
Testing JavaFX Applications
A Javafx testing library (also used by oracle when testing there new Javafx gui models - http://www.guigarage.com/2015/02/test-driven-development-youtube/ if you believe the people trying to sell you the library) provides a simple api to simulate actual human interaction with the application.
To start using TestFX, simply add the following elements to your pom.xml file:
<dependency>
<groupId>org.loadui</groupId>
<artifactId>testFx</artifactId>
<version>3.1.0</version>
</dependency>We start by creating a new class that extends GuiTest. Since GuiTest is abstract, our IDE will prompt us to implement the abstract method getRootNode:
public class LoginTest extends GuiTest
{
public Parent getRootNode()
{
//TODO
}
}This is generally how your TestFX test classes will look like:
class MyTest extends GuiTest {
public Parent getRootNode() {
return nodeUnderTest;
}
@Test
public static void nodeUnderTest_should_behaveInAParticularWay() {
// Test logic goes here.
}
}Here are the manuals specifing the TestFx api:
- Mouse: https://github.com/TestFX/TestFX/wiki/Mouse-Control
- KeyBoard: https://github.com/TestFX/TestFX/wiki/Keyboard-Control
- Assertions: https://github.com/TestFX/TestFX/wiki/Assertions
- Waiting: https://github.com/TestFX/TestFX/wiki/Waiting
Here are some examples from the Testfx github wiki:
Overview
Quick Start
Smarthouse Usage for Owners
Development Manuals
Continuous Development
Misc.