The exception, if uncaught, is unhelpful. So I catch it, print a helpful message, as in:
"Could not open input file XYZ"
What I really want to do is
1) Print a helpful message and terminate the application, if the mandatory file could not be opened (the application used to continue silently and produce empty results, which was confusing users).
2) Test that, if the file could not be opened, the message is indeed printed.
I guess I could choose to not terminate the application. Terminating would be more like the behavior I'd expect as a user, but like before, no harm would be done if I allow it to continue. It will just generate empty results. It could then be tested more easily.
I realize I could implement these behaviors with or without exceptions; the real problem is terminating/exiting the application with an error, which would exit the test.
I could use the "classical" approach - let the method return some value, maybe -1 instead of 0, and then test that value. I was hoping exceptions would be an improvement over that.......