开发者

Verify Log Messages written by Play!'s Logger class

When writing tests, is it possible to verify messages that have been written by Play!'s logg开发者_StackOverflow中文版er class?

So for example, if the production code below is executed:

Logger.error("boo boo");

In my test, am I able to verify that the message boo boo was written as an error to the logs?


The best way is to write your own log appender, which puts all data into a List. Then you can analyse the List at end of the test. Perhaps you can download such a logger from some sites. Another possibility is to use easymock to mock the appender, but I think this is more difficult, because you can't produce easily the expected LogEvent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜