Skip to main content

JUnit 5, Mockito, Controller Testing, TestFX UI and Event Testing

Learn JUnit 5, Mockito, Controller Testing, TestFX UI and Event Testing (Phase 14 · Testing and Debugging (Core), JavaFX) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Test strategy for JavaFX • Keep logic out of controllers (MVVM/MVP: a view model with properties and commands) so most tests are plain JUnit 5 + Mockito without the toolkit. Test properties and bindings directly (they are plain Java objects). Test controllers by injecting mocked services and calling handlers; test UI behaviour end-to-end with TestFX . UI tests are slower and flakier: keep them few and stable.

More lessons in Phase 14 · Testing and Debugging (Core)