[logback-user] Logging and test coverage
Joern Huxhorn
jhuxhorn at googlemail.com
Thu Feb 12 12:40:59 CET 2009
Hi everybody.
I was wondering if somebody has found a solution for the problem that
logging - in general, not just using Logback - lowers the coverage of
application code because code after
if(logger.isDebugEnabled())
is either executed or not, but not both, by the tests.
It would be necessary to execute every test-method twice: once logging
ALL and once logging OFF.
Ignoring cases like that is not the solution because it can actually
happen that a bug is enclosed or caused by such an if scope.
It once happened that a variable was initialized inside of a larger
if(logger.isDebugEnabled()) by mistake.
This resulted in a behavior where everything worked until the logging
level of that class was raised from DEBUG to INFO - which was a little
bit nasty because everything would work again after lowering the level
to DEBUG to look what's wrong... :p
Does anyone have a good idea (or even a solution) how to tackle that
problem?
Regards, Joern.
More information about the Logback-user
mailing list