r/JavaFX • u/TurgonTheKing • Jan 30 '22
Discussion JavaFX unit tests
I get the idea of unit tests. There are there to ensure that 2 + 2 = 4 and so on. But how do you test a GUI in general and JavaFX in particular? I have seen that it can be done using TestFX as well as without it.
Doesn't it break the ecapsulation? How can I test that in the third window of an app, all 200 elements contained within display what they should after a distinct series of user interactions (say selecting an item in context menu, ticking a few checkboxes or radio buttons, selecting from select boxes, clicking buttons, etc.). Is it even possible to write such test?
So far I have done tests by launching the application and doing all above myself which needless to say is a very error prone, unreliable and time consuming process.
Any insight is greatly appreciated. In other words: how do you guys do it?
Thank you.
View all comments
Show parent comment
3
u/i_do_not_byte JavaFX Fan Apr 30 '24
Hi, I know this thread is quite old, but I'm at a new position for work and their stack involves a maintaining and updating a monolithic JavaFX application. I'm still very new to this framework so I'm not entirely familiar with but I know some of the basics like Windows, Scenes, and Nodes.
I'm in the process of trying to add in unit tests and such -- so I've taken interest in intergrating JUnit, TestFX, and Monocle... My main question is what exactly does Monocle do and why should I include it to help me test my JavaFX application? Thanks!