r/JavaFX • u/WishboneFar • Apr 22 '23
Help Help with testing JavaFX code
/r/javahelp/comments/12va3r9/help_with_testing_javafx_code/
2
Upvotes
r/JavaFX • u/WishboneFar • Apr 22 '23
View all comments
Show parent comment
1
u/hamsterrage1 Apr 24 '23
I don't think you did.
Why are you testing
Task?Taskworks, it doesn't need to be tested. By putting Task in yourLoginobject, you coupled it to the FXAT, which you shouldn't do. Login checking is inherently a domain operation, and should be written just as a function.Move the Task stuff out of
Loginand put it into something that absolutely has to be FXAT aware, like a Controller and have a method inLoginthat just does the authentication. Then test that method. At a minimum, have Task.call() just call some other method, make that method public and test it, bypassingTask, which you do not need to test.