Issue
This Content is from Stack Overflow. Question asked by Duke
I have a javafx application which has a few fields, like an anchorPane. In its .fxml file, that anchorPane has a few fields like these
How can I test these values? I’m sure that JUnit can test object values, so I was wondering if I can make something like
Assertions.assertThat(mainAnchorPane.getId()).isEqualTo("mainAnchorPane");
Not sure but that might be as simple as instantiating an entity class (lets name it Person) and do something like
Person person = new Person("Maria");
Assertions.assertThat(person.getName()).isEqualTo("Maria");
The point here is that I’m not sure how can I inject the object values from my class into the tests, assuring that Person (or AnchorPane) from my class has the same values in my test.
Any thoughts?
Thanks in advance!
Solution
I don’t know if you already thought about this, but there is a test library called TestFX. It is made to test JavaFX applications easily. Maybe it can help you:
https://github.com/TestFX/TestFX/
For example you can proof the input of textfields or simulate mouse clicks. You can find more information on the given url.
This Question was asked in StackOverflow by user17575267 and Answered by Jaster_Master It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.