megster.net

Nathan Russell

Nathan Russell

Posts Categorized / java

Unit testing log4j method calls with jUnit and mockito

June 6, 2014 | java | by admin

Quite often we’ll write java code with an else or catch block, and will simply write a log4j logging statement within it. Consider the following method (deliberately simple and pointless for the purpose of this post) public List<String> addToListIfSizeIsUnder3(final List<String> list, final String value) { if (list == null) { LOGGER.error(“A null list was passed […]