How to test for I/O failure?

I have a try catch block in UI component’s controller class. The catch block catches IOException thrown by FXMLLoader’s static ‘load()’ method, I think. The exception is caught, logged using logger + shown to user in the form of a custom alert. I’ve tried using mockito and mocking fxml loader’s static load() method alongside TestFx for Junit5… but nothing seems to work. How does one test for IOException thrown as a result of user interaction?
No description
6 Replies
JavaBot
JavaBot4w ago
This post has been reserved for your question.
Hey @moa! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st4w ago
You could pass the name of the FXML file as an argument or similar and then use the name of a nonexisting file or you say "that shouldn't happen, I am not testing it"
moa
moaOP4w ago
@dan1st | Daniel by Mocking the controller’s method or FXMLLoder?
dan1st
dan1st4w ago
that might be possible as well but I meant changing adding a parameter to the method
moa
moaOP4w ago
This method is an onAction event handler method though
JavaBot
JavaBot4w ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server