When doing the Red, Green & Refactor cycle we should always write the minimum code to pass the test. This is the way I have been taught about TDD and the way almost all books describe the process.
But what about the logging?
Honestly I have rarely used logging in an application unless there was something really complicated that was happening, however, I have seen numerous posts that talk about the importance of proper logging.
So other than logging an exception I couldn't justify the real importance of logging in a proper tested application (unit/integration/acceptance tests).
So my questions are:
- Do we need to log if we are doing TDD? won't a failing test reveal what wrong with the application?
- Should we add test for the logging process in each method in each class?
- If some log levels are disabled in the production environment for example, won't that introduce a dependency between the tests and enviroment?
- People talk about how logs ease debugging, but one of the main advantages about TDD is that I always know what's wrong due to a failing test.
Is there something I am missing out there?