4 ms·
You can use log and monitoring signals to whitebox test certain implementation details to an otherwise stateless interface. I would say it's not great practice
by tlarkworthy 6y ago
You can use log and monitoring signals to whitebox test certain implementation details to an otherwise stateless interface.
I would say it's not great practice, but, it can remove a lot of contortions to be able to make assertions about the execution path taken when doing a unit test.
If I have a tricky thing to test. I ask, if I added the required operational monitoring (e.g. queue sizes)? Would I suddenly be able to test this easier? Would it make the test more self explanatory. If the answer is yes I might add the monitoring and then do the unit testing. If the answer is no I have to refactor the implementation for testability.
conclusion: exposing logs and especially monitoring counters to unit tests can actually super charge your testing and leave you net positive