This is something I often struggle with in testing, yet can never find a canonical or reasonable answer to.
f(), takes a file, processes it, and returns the processed file.
f() has unit tests to check that it performs as expected.
A command-line interface application (CLI) takes a file path as input and uses
f() to process the corresponding file.
How should I test the CLI? Passing it a path and ensuring that it handles that path — whether or not the file exists — is logical, but then passing that file to
f() and checking the output is exactly what I'm doing in the unit tests for
f(). It is redundant and twice as much work. Further, maintaining the tests when the function changes is twice as much work again.
f() can be anywhere — in a library that someone else has written, for example, or part of the whole program itself. I'm trying to understand best practices in (not) redundantly testing functionality, not just in this small example.