1

I was updating my application from JDK 8 to 13 and to Javafx 13. Updated all dependencies to the latest updated ones. But now one of my tests returns error. The public void start(Stage stage) is not called on initialization, but on After the function public void tearDown() is called, closing a null application.

I can't understand why the start is not being called.

public class AppUiChooseDownloadFolderTestIT extends BaseUiTestIT {
    @Before
    public void setUp() throws Exception {
        LOG.info("Starting test case {}", testname.getMethodName());
    }

    @Override
    @After
    public void tearDown() {
        // Nothing
    }
}
public class BaseUiTestIT extends ApplicationTest {
    protected App app;

    @Override
    public void start(Stage stage) throws Exception {
        app = Mockito.mock(App.class);

        Injector.injectMembers(BaseUiTestIT.class, this);
        Mockito.doCallRealMethod().when(app).start(Mockito.any());

        app.start(stage);
    }

    @After
    public void tearDown() {
        LOG.info("Stopping application {}", app);

        if (app != null)
         app.stop();

        closeWindows();
        LOG.info("Cleanup of app finished");
    }
}

Specifications

  • Version: 4.0.15-alpha
  • OpenJDK 13
  • JavaFX 13
  • Platform: Ubuntu
0009laH
  • 1,960
  • 13
  • 27

1 Answers1

1

Make sure you are using testfx-junit5 and not testfx-junit if you are using JUnit 5.

Tomas
  • 1,315
  • 10
  • 17