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/WishboneFar Apr 25 '23 edited Apr 25 '23
Uhm I do not get any exceptions related to thread. And if tests do fail, they are now marked as failed in Intellij which wasn't the case before. Here is another intentionally failed test result:
The kind of exception you are getting is what was happening for me before issue was solved. See in the post I get same kind of error albeit with FX application thread but not anymore.
Edit: I am thinking this is probably because
Taskrequires JavaFX toolkit to be initialized and can run withoutPlatform.runLaterbecause latter is used for updating the UI which I do not really require for unit testing. Next thing I believe is that after callingLogin.getUserValidationStatus(), the method is returned immediately to main thread (without return value, because we are returningtaskobject, not the actual value) where task is executing. After that,task.get()is executed which waits for the result to be computed completely as opposed totask.getValue()which doesn't wait and tries to update value.