4 ms·
The difference is that unit tests are checked automatically, and logs require manual inspection.
by jdlshore 3y ago
The difference is that unit tests are checked automatically, and logs require manual inspection.
- josephg 3y agoEyeballing a log is often enough to convince myself that some code is probably correct. It’s not as thorough as a unit test, but better than nothing if you weren’t planning on writing a test anyway. This can also be a great way to write your unit tests. Once you like what your code does in some situation, you can copy paste the input and expected output into a unit test to make sure you don’t break that correct behaviour later.
- Lio 3y agoThe other difference is that unit tests are usually quiet unless something is wrong but log statements are always noisy. When there's too much noise it becomes harder to see what's happening. You can turn down the log level but then you loose that visibility altogether.
- Supermancho 3y agoUnit test frameworks are the modern, convenient, methodology to control bubbling up an output, when multiple assertions fail. This is what observing the red (suite failed) or green (suite succeeded) is. Executing a suite requires a manual interaction (ie > run suite or > make build -> runs suite or > edit cron -> runs suite). In a way, all testing is still manual, but test suites allow us to scale testing, which logs do not (1million log files is impractical to use as testing output). That's why unit test frameworks are a good thing.