Printing a logging message to the console in a GWTTestCase
I'd li开发者_如何学Cke to debug some of my GWTTestCase and printing logging messages would probably be the easiest way to do it. Is there any way to do that?
If you're running the test in DevMode (i.e. you didn't pass -web or -prod to the JUnitShell) you can use System.out.println()
for some bare-bones logging.
Either use the standard GWT Logging mechanism as described here: http://code.google.com/webtoolkit/doc/latest/DevGuideLogging.html
That is an emulation of java.util.logging so you can call it on client, shared or server code and will all work.
Or, there is also the excellent gwt-log GWT library here: http://code.google.com/p/gwt-log/
Which is easy to add to your project.
Have you checked out http://code.google.com/webtoolkit/doc/latest/DevGuideLogging.html
private static Logger logger = Logger.getLogger("");
...
logger.log(Level.INFO, "Some stuff");
精彩评论