[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [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
Re:  junit test... for xslt2?
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
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".

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?




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>


Good example of a test 'group', each part being a simpler test (atomic test?)

Another good example where you are concerned about text content (the value 200 is pretty essential), where in other cases you really don't
care about content, but elements / attributes *must* be present or missing.





regards


--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.