Thursday, May 27, 2004

Tapestry Test Assist

A frequent criticism of Tapestry, from the point of view of the Test Driven Development crowd, is that Tapestry is too hard to test ... because all your classes are abstract.

As a stop-gap measure, I've finally gotten around to creating Tapestry Test Assist. This is a simple class, that can be used inside test suites, to instantiate abstract Tapestry pages and components (or any other abstract class, for that matter).

Like Tapestry itself, the AbstractInstantiator will create new fields and methods in the subclass. Unlike Tapestry, it isn't driven by an external specification; it just finds each property that is abstract (i.e., has an abstract getter and/or setter method) and implements the property in a subclass, with a field and pair of accessor methods. Unlike Tapestry, these accessors are very simple, with no hooks into Tapestry persistent page property logic ... and that's fine for testing.

The source code is available as a zipped-up Eclipse workspace. The easiest thing is just to copy the couple of source files into your own test suite. Eventually, this will be part of the actual Tapestry distribution.

3 comments:

  1. Howard, pls, can u giv an example of how 2 test a tapestry app/ page with test assist. i understand i would need easymock to generate a plethora of classes. it would be easier 2 achieve wit an example. the gmane tapestry-user list is not searchable and i get no useful results after searching google for tapestry testing. thanks in advance.

    ReplyDelete
  2. Anonymous4:08 PM

    Hey Howard, do not forget about us: Tapestry fans. It is very important to us, XP followers, to have a well established testing platform. Please help us understanding how to use the AbstractInstatiator.

    ReplyDelete
  3. Anonymous11:11 PM

    Apparently this is now part of Tapestry as the class org.apache.tapestry.test.Creator.

    ReplyDelete

Please note that this is not a support forum for Tapestry. Requests for help will be deleted. Please subscribe to the Tapestry user mailing list if you are in need of support, or contact me directly for professional (for pay) support.

Spammers: Don't bother. I delete your comments and it's a waste of time for both of us. 垃圾邮件发送者:不要打扰。我删除您的评论和它的时间对我们双方的浪费