When I try to perform unit tests on components which contain JavaFX controls I get a java.lang.IllegalStateException: Toolkit not initialized.
How can components be unit tested which operate with JavaFX controls?
When I try to perform unit tests on components which contain JavaFX controls I get a java.lang.IllegalStateException: Toolkit not initialized.
How can components be unit tested which operate with JavaFX controls?
Just declare and initialize a JFX Panel. Like:
@Test
public void test() throws Exception {
JFXPanel fxPanel = new JFXPanel();
[.. Begin tests ..]
}
It is the easy way...
Similar to @multiplayer1080 answer but more elegant...
import javafx.application.Platform
@BeforeAll
static void initJfxRuntime() {
Platform.startup(() -> {});
}