Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

•Re: Testing Template, or should I write a diff for TT templates?

by merlyn (Sage)
on Nov 14, 2003 at 18:11 UTC ( [id://307137]=note: print w/replies, xml ) Need Help??


in reply to Testing Template, or should I write a diff for TT templates?

The fact that it uses a templating engine is merely a distraction. What you actually have is a system that outputs certain text.

Consider it a black box. For some given set of inputs, it should produce an acceptable output text.

What defines that acceptability? That's what you test. If you use a regex-based engine or a literal match, that's up to you. If someone checks in a template that fails that test, then you either fix the template or fix the test.

For example, you could have as one of your acceptance standards that it forms valid XML. So part of your test, you parse the XML. If it fails, that's not acceptable.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Testing Template, or should I write a diff for TT templates?
by EvdB (Deacon) on Nov 14, 2003 at 18:21 UTC
    Do you mean something like this:
    Template: blah blah [% user.name %] blah, blah. Test data: $$vars{user}{name} = "<<<<<< user.name >>>>>>" Template produces: blah blah <<<<<< user.name >>>>>> blah, blah. Testing code: ok( $output =~ m/<<<<<< user.name >>>>>>/ );
    However this method could easily lead to very involved tests for complicated pages - and testing the test code could become trickier than testing the template.

    Also if I have understood you correctly it will make it difficult to test real world data. As I see it the only really good way to test the templates is to create simplified ones and then to check the output against known good results - even if that is more labour intensive.

    --tidiness is the memory loss of environmental mnemonics

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://307137]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 08:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found