flâneur — a map of the web's best reading

A quick one: Testing log messages — Camille Fournier

camilletalk.com · 260 words · saved by 1 readers

I'm writing a talk on unit testing for work, and it reminded me of one of the coolest things I learned from the ZK code base with respect to testing: testing log messages. You probably don't want to rely too heavily on log messages for testing, but sometimes it's the only indication you have that

I'm writing a talk on unit testing for work, and it reminded me of one of the coolest things I learned from the ZK code base with respect to testing: testing log messages. You probably don't want to rely too heavily on log messages for testing, but sometimes it's the only indication you have that a certain condition happened. So how do you test it? Layout layout = Logger.getRootLogger().getAppender("CONSOLE") .getLayout(); ByteArrayOutputStream os = new ByteArrayOutputStream(); WriterAppender appender = new WriterAppender(layout, os); appender.setImmediateFlush(true); appender.setThreshold(Lev

Explore this link on the map →

related reading