4 ms·
A log statement isn't a unit test in the same way that apples aren't trees. A unit test is a discrete, runnable program that asserts some state about your progr
by ludston 3y ago
A log statement isn't a unit test in the same way that apples aren't trees. A unit test is a discrete, runnable program that asserts some state about your program to be true, whereas a log is just some subsystem of your overall program that prints some output with no pass/fail condition.
You may have a unit test that makes assertions about logs though? I would definitely expect somebody that isn't a junior programmer to understand this.
- Supermancho 3y ago> A log statement isn't a unit test in the same way that apples aren't trees I don't think your explanation is compelling. > a log is just some subsystem of your overall program that prints some output with no pass/fail condition. The pass fail is interpreted. A unit test result is interpreted, be it with a big green/red or an exception or any other way you wish to express it. Running something manually and checking the logs in an environment, when there is a reported issue, is modus operandi of every developer today. Did A happen and B happen and what did C say before exit? A looks good (because it has an expected state), etc. > I would definitely expect somebody that isn't a junior programmer to understand this. I didn't say logs were a replacement for unit tests (that's a previous poster's strawman). Regardless, they are a form of testing, because we use them to observe state after execution. Manual testing is testing, manual testing and observation of logs, is testing.
- ludston 3y agoYou explicitly said logging is a form of "unit test" which has a very specific meaning and a log is not it. Observing a log can obviously be part of an assertion in a test be it manual or whatever, but an assertion is not a unit test.
- Supermancho 3y ago> A unit test is a discrete, runnable program that asserts some state about your program to be true I would say "Observe the state of an execution stack". Tomato tomato. > which has a very specific meaning Unit testing is a methodology, not a specific thing. How you observe it, be it through a pass fail indicator or a "This looks right", is immaterial. Splitting hairs on the output methodology does not change the utility.