There seems to be two trends on this topic:
Should unit tests log what they do? Would those additional informations be helpful in the unit test reports? Or should unit tests be silent as long as they don't fail?
My question targets Java unit tests, but input from programmers in other languages could be interesting as well.
The Test Log contains detailed information on all the executed tests, including all the script routines, keyword tests, low-level procedures, and so on. It contains the results of test operations in each test. It can also include images of the tested applications, links to files, and other entries.
This is obviously a bit subjective, but I don't see why you would disable logging in your unit tests.
I do think you're misinterpreting the first linked post; the poster is not claiming that you shouldn't log anything, he's saying that a pass/fail should not be something that is just in the logs. It should be returned to the testing framework. It should be a piece of data that is completely seperate from the normal logs.
I agree with him on that.
Apart from that you could still have your normal logging. You have it anyway in the classes you're testing (or should have). When a test fails, you might see something in the log which will help you debug it more quickly. I don't see how this could ever be a negative point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With