XSLT Unit Test (XSpec)
XSpec is a behavior driven development (BDD) framework for XSLT and XQuery. XSpec consists of a syntax for describing the behavior of your XSLT or XQuery code, and some code that enables you to test your code against those descriptions.
To create an XSLT Unit Test, go to Navigator view. Oxygen XML Developer plugin allows you to customize the XSpec document when you create it. In the customization dialog box, you can enter the path to an XSL document or to a master XSL document.
. You can also create an XSLT Unit Test from the contextual menu of an XSL file in theTo run an XSLT Unit Test, open the XSPEC file in an editor and click Apply Transformation Scenario(s) on the main toolbar.
Note
When you create an XSpec document based on an XSL document, Oxygen XML Developer plugin uses information from the validation and transformation scenarios associated with the XSL file. From the transformation scenario Oxygen XML Developer plugin uses extensions and properties of Saxon 9.6.0.7, improving the Ant scenario associated with the XSpec document.
New XSLT Unit Test Wizard
An XSpec file contains one, or more test scenarios. You can test a stylesheet in one of the following ways:
- Test an entire stylesheet.
Testing is performed in a certain context. You can define a context as follows:
- Inline context, building the test based on a string.
<x:scenario label="when processing a para element"> <x:context> <para>...</para> </x:context> ... </x:scenario>
- Based on an external file, or on a part of an external file extracted with an
XPath expression.
<x:scenario label="when processing a para element"> <x:context href="source/test.xml" select="/doc/body/p[1]" /> ... </x:scenario>
- Inline context, building the test based on a string.
- Test a function.
<x:scenario label="when capitalising a string"> <x:call function="eg:capital-case"> <x:param select="'an example string'" /> <x:param select="true()" /> </x:call> ... </x:scenario>
- Test a template with a name.
<x:call template="createTable"> <x:param name="nodes"> <value>A</value> <value>B</value> </x:param> <x:param name="cols" select="2" /> </x:call>