Basic JUnit test for JavaFX 8

后端 未结 3 872
难免孤独
难免孤独 2020-11-27 19:19

I want to create basic JUnit test for JavaFX 8 application. I have this simple code sample:

public class Main extends Application {
    public static void ma         


        
3条回答
  •  被撕碎了的回忆
    2020-11-27 19:39

    I use a Junit Rule to run unit tests on the JavaFX thread. The details are in this post. Just copy the class from that post and then add this field to your unit tests.

    @Rule public JavaFXThreadingRule javafxRule = new JavaFXThreadingRule();
    

    This code works for both JavaFX 2 and JavaFX 8.

提交回复
热议问题