Unit testing ActionHandlers with Guice

Skip to first unread message

David Chandler

Oct 21, 2009, 11:06:49 AM10/21/09
to GWT Dispatch
Inspired by Chris Lowe's recent blog on MVP unit testing, I've worked
out an approach for testing ActionHandler server-side code by calling
them from a DispatchTestService. This has been especially helpful for
rapid testing of AppEngine JDO calls in my ActionHandlers
independently of the client. It's so simple I'm almost embarrassed to
publish it, but that's part of the beauty of gwt-dispatch! At any
rate, I will be grateful for suggestions of any enhancements /
improvements to this approach. Once I get a little feedback, I'll post
a wiki page on ActionHandler unit testing.


David Chandler

David Peterson

Oct 21, 2009, 1:55:07 PM10/21/09
to gwt-di...@googlegroups.com
Hi David,

Looks interesting. One note from my quick scan - you may want to
consider ways of injecting some of the stuff which is currently coming
via 'factory' classes directly in your code, particularly if you're
using Spring or Guice (I'm assuming the latter in your case). That
will make it simple to swap out the services provided by those
factories when testing more complex situations. Plus, it's cleaner all
round anyway :)


David Chandler

Oct 21, 2009, 2:40:18 PM10/21/09
to gwt-di...@googlegroups.com
Great idea, thanks! I'll move the PersistenceManagerFactory into
Guice. Sooner or later, I think the ActionHandlers will need a
different PersistenceManager in test, although changing out the whole
AppEngine environment works for now.

Reply all
Reply to author
0 new messages