testing

Testing tools, testing philosophy & methodology...
tees 2020-04-27T01:11:43.007500Z

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.

seancorfield 2020-04-27T03:24:17.008500Z

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?

seancorfield 2020-04-27T03:24:39.009Z

Are you talking about testing the function within the code of the CLI tool?

seancorfield 2020-04-27T03:30:04.010600Z

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

tees 2020-04-27T13:43:54.011700Z

@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.