maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benoît Berthonneau <ben...@berthonneau.com>
Subject Code coverage with debug logs: 100% branch coverage not possible?...
Date Wed, 12 Feb 2014 20:30:52 GMT
Hi all,

 

I need your opinion/way to tackle the following problem:

In many projects we use a Logger (doesn’t matter which implementation). It
is often recommend to test if the debug level is activated before logging a
debug trace like the following:

if (logger.isDebugEnabled()) {

    logger.debug(“blah ” + i + “ in the loop that contains ” + max);

}

 

Now when you run unit tests on this kind of code you need to make a choice:
run tests with INFO level or run tests with ALL traces activated. I choose
the second option in order to:

*         Check that debug traces doesn’t throw unwanted exception (like
NPE)

*         Have a better code coverage in term of covered lines

 

But in term of branches coverage we could never have a 100% :(

 

To me the only way to cover this is to run the tests suite 2 times: one with
INFO traces configured, and another one with ALL traces activated.

Did you face this issue and how did you solve it ?

 

Thanks,

Benoît.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message