0x4a616e / TestFX

Simple and clean testing for JavaFX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TestFX

Build Status Maven Central

Simple and clean testing for JavaFX.

Current Status

Working towards version 4.0.0 on master. The changelog wiki page is pretty out-dated and latest documentation only available via gradle javadoc.

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.
  • The JUnit testing framework and Hamcrest matchers.
  • Screenshots of failed tests.
  • Headless testing using Monocle.

Example

public class DesktopPaneTest extends FxRobotTestBase {
    @Before
    public void setup() throws Exception {
        setupSceneRoot(() -> new DesktopPane());
        showStage();
    }

    @Test
    public void should_drag_file_to_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"));
    }
}

Maven and Gradle

Gradle build.gradle:

dependencies {
    testCompile "org.testfx:testfx-core:4.0.0-SNAPSHOT"
}

repositories {
    maven { 
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}

Maven pom.xml:

<dependencies>
    <dependency>
        <groupId>org.testfx</groupId>
        <artifactId>testfx-core</artifactId>
        <version>4.0.0-SNAPSHOT</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>sonatype-snapshots-repo</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <snapshots>
            <enabled>true</enabled>
       </snapshots>
    </repository>
</repositories>

Documentation

Motivation

The motivation for creating TestFX was that the existing library for testing JavaFX, Jemmy, was too verbose and unwieldy. We wanted more behavior driven tests with easy-to-read code that our tester could follow and modify on her own.

Today, TestFX is used in all of the about 100 automated GUI tests in LoadUI (video).

Similar Frameworks

  • Jemmy, by the Oracle SQE team.
  • Automaton, a new testing framework that supports JavaFX as well as Swing.
  • MarvinFX, test support for JavaFX Propertys.

Mailing List

Head over to testfx-discuss@googlegroups.com for discussions, questions and announcements.

Credits

TestFX was initially created by @dainnilsson and @minisu as a part of LoadUI in 2012. Today, it is being extended and maintained by @hastebrot, @Philipp91, @minisu and the other contributors.

License

Copyright 2013-2014 SmartBear Software
Copyright 2014-2015 The TestFX Contributors

Licensed under the EUPL, Version 1.1 or - as soon they will be approved by the
European Commission - subsequent versions of the EUPL (the "Licence"); You may
not use this work except in compliance with the Licence.

You may obtain a copy of the Licence at:
http://ec.europa.eu/idabc/eupl

Unless required by applicable law or agreed to in writing, software distributed
under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the Licence for the
specific language governing permissions and limitations under the Licence.

About

Simple and clean testing for JavaFX.

License:Other


Languages

Language:Java 99.4%Language:Groovy 0.6%