testfx

How to test JavaFX (MVC) Controller Logic?

天大地大妈咪最大 提交于 2019-12-05 21:53:17
How do we properly write unit/integration tests for the JavaFX Controller logic? Assuming the Controller class I'm testing is named LoadController , and it's unit test class is LoadControllerTest , my confusion stems from: If the LoadControllerTest class instantiates a new LoadController object via LoadController loadController = new LoadController(); I can then inject values into the controller via (many) setters. This seems the only way short of using reflection (legacy code). If I don't inject the values into the FXML controls then the controls obviously aren't initialized yet, returning

Headless testing with JavaFx and TestFx

不想你离开。 提交于 2019-11-29 04:46:45
I have a simple JavaFx application (Java 8) that has a unit test using TestFx. However, when the test is run, the application window starts up and the mouse is moved to do whatever action is in my test. Can these tests be run in a way where the application doesn't popup and I can still use my mouse for other things as the automated build and tests are running? Update: I found this blog post that provides the solution for me to this problem. As the author suggests, you need to add the following dependency to your build: testRuntime 'org.testfx:openjfx-monocle:1.8.0_20' Then you will need to

Headless testing with JavaFx and TestFx

孤者浪人 提交于 2019-11-27 18:45:40
问题 I have a simple JavaFx application (Java 8) that has a unit test using TestFx. However, when the test is run, the application window starts up and the mouse is moved to do whatever action is in my test. Can these tests be run in a way where the application doesn't popup and I can still use my mouse for other things as the automated build and tests are running? 回答1: Update: I found this blog post that provides the solution for me to this problem. As the author suggests, you need to add the