[XSL-LIST Mailing List Archive Home]
[Reply To This Message]
Re: junit test... for xslt2?
Subject: Re: junit test... for xslt2?|
From: Dave Pawson <davep@xxxxxxxxxxxxx>
Date: Mon, 08 Mar 2010 10:45:33 +0000
On 08/03/10 10:06, Florent Georges wrote:
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
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".
Not sure what I'd like to call it!
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?
Good example of a test 'group', each part being a simpler test (atomic
Another good example where you are concerned about text content (the
value 200 is pretty essential), where in other cases you really don't
Here is a simplified exerpt of a test suite for the EXPath HTTP
<!-- some param here... -->
<t:expect test="count($t:result) eq 2"/>
<t:expect test="$t:result instance of element(http:response)"/>
<t:expect test="$t:result/xs:integer(@status) eq 200"/>
care about content, but elements / attributes *must* be present or missing.
XSLT XSL-FO FAQ.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format