Subject: Re: [xsl] junit test... for xslt2? From: Dave Pawson <davep@xxxxxxxxxxxxx> Date: Mon, 08 Mar 2010 10:45:33 +0000 |
A couple of remarks here.
If we speak about the result of a "whole transform", I tend to see it as defined by an input and an output, so the result can be tested against an expected output. As a few values can not depend on the input (like generate-id()) we need a mechanism to compare two documents (where we can say: "do not compare text nodes with whitespaces", or "do not compare the value of the attributes 'id'").
This is where I'm hoping 'structure checking' is possible using xpath only? The poor mans xml diff. I wonder how well Schematron fits this model.
But then this is more "functional testing" than "unit testing".
For unit testing, I'd say one component has only a few responsibilities on the result it produces. It does not always define its whole output. Some parts are the responsibility of other components (like called functions or other template rules). And in unit testing, I think assertion expressions (what I think you mean by "you just need to execute XPaths against it") is really more convenient than comparing two entire trees.
This backs up your idea of keeping templates 'simple' or single purpose? Surely the difference is simply one of 'level'? Test one template vs test a tree of templates?
Here is a simplified exerpt of a test suite for the EXPath HTTP Client:
<t:call function="http:send-request"> <!-- some param here... --> </t:call> <t:expect test="count($t:result) eq 2"/> <t:expect test="$t:result[1] instance of element(http:response)"/> <t:expect test="$t:result[1]/xs:integer(@status) eq 200"/> <t:expect test="$t:result[2]/*"> <pass>...</pass> </t:expect>
-- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] junit test... for xslt2?, Dave Pawson | Thread | Re: [xsl] junit test... for xslt2?, Dave Pawson |
Re: [xsl] How to emit opening and c, David Carlisle | Date | Re: [xsl] junit test... for xslt2?, Dave Pawson |
Month |