Unit Testing DTML and ZPT
Is there any standard way of unit testing the two page templating methods in Zope 2? Chris
--On 25. Juli 2007 18:46:13 -0400 Chris Gray <cpgray@library.uwaterloo.ca> wrote:
Is there any standard way of unit testing the two page templating methods in Zope 2?
What does that mean? You might look at the unittests for ZPT and DTML. -aj
On 7/26/07, Chris Gray <cpgray@library.uwaterloo.ca> wrote:
Is there any standard way of unit testing the two page templating methods in Zope 2?
Chris
If you're trying to test the output produced by a dtml/zpt, you could try to invoke it, inside a zopetestcase. Something like: self.app.index_html = PageTemplateFile(path_to_your_template, globals()) x = self.app.index_html(); self.assertEquals("some_string", x); I'm using here PageTemplateFile, but you can do it with standard ZopePageTemplate. The problem is what you're trying to test (and, therefore, to assert). Checking for equality is too fine grained, where you would check for the structure of the zpt, for example. A little parser could be useful. Regards Marco -- Marco Bizzarri http://iliveinpisa.blogspot.com/
On Thu, Jul 26, 2007 at 01:09:54PM +0200, Marco Bizzarri wrote:
The problem is what you're trying to test (and, therefore, to assert). Checking for equality is too fine grained, where you would check for the structure of the zpt, for example. A little parser could be useful.
testbrowser might come in handy: http://plone.org/documentation/tutorial/testing/functional-tests/view?search... It's also good to keep the "design for testing" adage in mind. Keep it granular. Do as much logic and data preparation as possible in product methods or scripts, which can be tested individually. Then your templates simply present this data. -- Paul Winkler http://www.slinkp.com
participants (4)
-
Andreas Jung -
Chris Gray -
Marco Bizzarri -
Paul Winkler