Re: [htmltmpl] Testing HTML::Template templates
Brought to you by:
samtregar
From: Michael P. <mp...@pl...> - 2006-09-11 13:55:37
|
Justin Simoni wrote: > Does anyone else have a better strategy for testing the structure of > their HTML::Template templates? I've done 2 things in the past. 1) Load each template, use the query() method to find out what the vars and loops are and fill them in with fake data. Then test the output. PROS: * you can make sure your tmpl_* syntax isn't fatally wrong * you don't need to worry about templates being valid HTML, just the resulting output. CONS: * you're still at the mercy of something like HTML::Lint and it's bugs * you're not testing whether or not someone mispelled a variable name, etc 2) Test the modules that use the templates, not the templates themselves. PROS: * Tests not only the logic in the controller classes, but also that the vars are being passed correctly to the template with the right names. CONS: * Not as easy to write. You can't just write one test that tests all your templates. Plus you need to make sure you exercise every case so that every template is used. I prefer #2. -- Michael Peters Developer Plus Three, LP |