#How to test for I/O failure?

10 messages · Page 1 of 1 (latest)

coarse slate
#

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?

ashen tinselBOT
#

This post has been reserved for your question.

Hey @coarse slate! 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.

barren drift
#

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"

coarse slate
#

@barren drift by Mocking the controller’s method or FXMLLoder?

barren drift
#

but I meant changing adding a parameter to the method

coarse slate