it isn't a new issue for sure, but I couldn't find a nice solution for my problem, so I will try to find one on my own.
I have given an Application
class:
import javafx.application.Application;
import javafx.stage.Stage;
public class TestApplication extends Application {
@Override
public void init() throws Exception {
// ...
super.init();
}
@Override
public void start(Stage primaryStage) throws Exception {
// ...
}
@Override
public void stop() throws Exception {
// ...
super.stop();
}
}
Now, I want to test methods from its controller and so on.. Not the GUI, but other things.
So, for this, I thought, I create an instance
of this Application
, start it and then I make something like instance.getXY(...)
. Is it the right purpose?
A little example for a JUnit
class:
import org.junit.Test;
public class JUnitTests {
@Test
public void testFoo() {
// this starts the application, but I don't get a reference from it
javafx.application.Application.launch(TestApplication.class);
}
}
I've found this Launch JavaFX application from another class to get an refrence of the Application
class. But it don't seems to be a nice solution for me.
How would you fix my testing problem?
Thanks for your help!