[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT Unit Testing and Coverage

Subject: Re: XSLT Unit Testing and Coverage
From: "Andrew Welch andrew.j.welch@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 May 2014 08:55:56 -0000
Re:  XSLT Unit Testing and Coverage
> is there a good reason to deploy a XSLT unit testing framework?

Yes it's essential!

> I have never
> seen any serious XSLT dev env where the XSLT unit testing was either done
> religiously, or considered mandatory.

If you are doing "serious" work then you need something to give you
confidence after making changes.

I have my own Java junit based test framework that allow me to do two things:

1) do xquery based asserts like this:

assertEquals(runQueryOnInput("/path/to/some/node"),
runQueryOnOutput("/path/in/the/result"))

the runQueryOnInput() and runQueryOutput() helper methods run xquerys
against the stored input and result docs.

2) Validate the result and/or do deep-equal() comparisons with some
expected doc.  The deep-equal approach is only occasionally useful
because unrelated changes can break a lot of tests.

XSLT often follows the structure of "specific imports common", and the
test framework follows that approach:

Specfic1Test extends CommonTest
Specific2Test extends CommonTest

Tests common to all go in CommonTest, and tests only for the SpecificN
go in there.  The good thing about this approach is it mirrors your
xslt structure, and allows the same overriding of tests as code in the
xslt.  Also, every time you add a new "specific" test class, you pick
up all the existing tests in common.

Ultimately this allows me to build up 1000s of focussed tests, on
hundreds of input files, each one comparing values in the input with
the result or checking for existence etc, and validating every result.
 It's all runs in seconds, and fits in with Java/Maven/Hudson for
continuous build.


-- 
Andrew Welch
http://andrewjwelch.com

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.