Curious how many test their logging statements here. To test that my
logging is what I expect it to be I usually create an instance
variable e.g. mLogMessage. I set it and log it, then check my
mLogMessage in my Junit test. This allows me to test what I'd expect
my log to be without checking the log file itself. The negative is
that I have a getLogMessage() which is only used by Junit. Wondered
what other approaches people use.
Roger Lindsjö - 09 Feb 2008 13:53 GMT
> Curious how many test their logging statements here. To test that my
> logging is what I expect it to be I usually create an instance
[quoted text clipped - 3 lines]
> that I have a getLogMessage() which is only used by Junit. Wondered
> what other approaches people use.
What logging framework are you using. You could probably create your own
log listener / handler (or whatever they are called in your framework)
which gives you access to logged messages from withing you unit test.
--
Roger Lindsjö