Warning: Declaration of Bootstrap_Walker_Nav_Menu::start_lvl(&$output, $depth) should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = Array) in /homepages/10/d412081534/htdocs/clickandbuilds/WordPress/wordpress/wp-content/themes/stanleywp/functions/function-extras.php on line 61
JavaFX JUnit Testrunner | buildpath.de

JavaFX Testrunner

 

I deployed a small JUnit TestRunner based on http://awhite.blogspot.de/2013/04/javafx-junit-testing.html into the maven central repository.

Project on GitHub

You can use it by adding the following dependency to your project:

<dependency>
        <groupId>de.saxsys</groupId>
        <artifactId>jfx-testrunner</artifactId>
        <version>1.0</version>
</dependency>

Some JavaFX components does need the JavaFX-Application to be initialized. The TestRunner ensures that you don’t have to mind about an existing JavaFX Application for your Unit Tests. In addition you can choose which test method should be performed in the UI-Thread  by using the Annotation @TestInJfxThread.

 

@RunWith(JfxRunner.class)
public class TestClass {

    @Test
    public void testWithoutFXThread() throws Exception {
        Assert.assertFalse(Platform.isFxApplicationThread());

        CompletableFuture isInApplicationThread = new CompletableFuture<>();
        
        Platform.runLater(() -> {
            isInApplicationThread.complete(Platform.isFxApplicationThread());
        });
        
        Assert.assertTrue(isInApplicationThread.get());
    }

    @Test
    @TestInJfxThread
    public void testWithFXThread() throws Exception {
        Assert.assertTrue(Platform.isFxApplicationThread());
    }
}
Share Button

0 Comments

  1. Pingback: JavaFX und Spring verbinden und Testen | RoboRally

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>