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.
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 :)
> 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.
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.
On Wed, Oct 21, 2009 at 1:55 PM, David Peterson <da...@randombits.org> wrote:
> 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
> On 22/10/2009, at 1:06 AM, David Chandler wrote:
>> 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.