this might be a fairly language agnostic question, but... I'm building a cli tool with clojure - when a user has the option to do something that could fail (say, slurping a file that doesn't exist, or the file is invalid); I'm wondering how people might test for this? Currently I am printing an message to the console when the user does something incorrectly to inform what went wrong, but then I either return false or an empty value and also test for that. Should I be throwing some kind of error and can test with (is (thrown? ...
? I would prefer to just return a nice clean println string and not a stack trace.
If it's a CLI tool, I would expect it to exit with a zero status for success, or non-zero for failure. Am I misunderstanding you?
Are you talking about testing the function within the code of the CLI tool?
At what level are you trying to test this? You can certainly test by running a command (your command line tool) and capturing its stdout, stderr, and its exit code, and then you can write assertions against those @tees
@seancorfield - thanks for the input. I'm writing about testing the function within the code - but it's also good to know your thoughts on what should actually happen with the functionality when an end user is using the tool. So, I suppose you answered my questions both asked and unasked.