One of the recommendations when writing well designed applications is to separate concerns. So one function to get input. Another to do the computation (business logic). A third function to generate the output.

Unfortunately in many applications people mix these things. Especially if they have not tried to test the application.

So when you start writing tests to such an application, one that might have functions with hundreds or thousands of lines of code, you need to be able untangle the code.

In this article we'll override the input and output of a CLI (Command Line Interface) based application.