https://github.com/npryce/xsltest
XSLTest: XSLT easy stylesheet testing
https://github.com/npryce/xsltest
Last synced: 5 months ago
JSON representation
XSLTest: XSLT easy stylesheet testing
- Host: GitHub
- URL: https://github.com/npryce/xsltest
- Owner: npryce
- Created: 2011-08-26T09:39:08.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2011-09-08T11:52:17.000Z (almost 15 years ago)
- Last Synced: 2025-01-30T07:28:35.054Z (over 1 year ago)
- Homepage:
- Size: 109 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
XSLTest: XSLT easy stylesheet testing
=====================================
Requirements:
-------------
* An XSLT 2 processor, such as Saxon.
* A web browser to view the test reports.
Overview
--------
XSLTest lets you test XSLT transforms and functions using a mix of
XSLT code, XSLTest elements that define assertions and test suites and
embedded HTML documentation.
An XSLTest suite is an XSLT stylesheet with named templates that
generate HTML and also contain XSLTest elements.
The XSLTest framework acts as a compiler: the `xsltest.xslt`
stylesheet translates a test suite into a stylesheet that performs the
assertions and generates results in XML format. XSLTest's
`report.xslt` stylesheet translates the results into an HTML report.
XSLTest also provides a stylesheet, `test-abort-build.xslt`, that
fails if the results XML contain any test failures. This is useful
for aborting the build when tests fail.
Example tests written with XSLTest can be found here:
[https://github.com/npryce/courseware-html/tree/master/tests](https://github.com/npryce/courseware-html/tree/master/tests)
Test Suite Structure and XML Namespaces
---------------------------------------
XSLTest elements are defined in the namespace http://www.natpryce.com/xsltest/1.0.
The entry-point to a test suite is a named XSLT template. For example:
Tests for My Code
... assertions and suites go here ...
Example Makefile Rules
----------------------
The following example Makefile rules implement the XSLTest processing pipeline.
build/testing/%.xslt: src/%-test.xslt
@mkdir -p $(dir $@)
saxon -xsl:$(XSLTEST_HOME)/xsltest.xslt -s:$< -o:$@
build/testing/results.xml: $(XSLT_TESTS:tests/%.xslt=build/testing/%.xslt) $(XSLT)
saxon -xsl:build/testing/all-tests.xslt -it:all-tests -o:$@
build/testing/report.html: build/testing/results.xml
saxon -xsl:$(XSLTEST_HOME)/report.xslt -s:$< -o:$@
# Avoid saxon's slow startup if we can say for sure that no tests failed
check: build/testing/report.html
@if grep -q -m 1 'result="failed"' build/testing/results.xml; then \
saxon -xsl:$(XSLTEST_HOME)/test-abort-build.xslt -s:build/testing/results.xml; \
fi
The rules assume that:
* The variable XSLTEST_HOME refers to the directory containing the XSLTest stylesheets.
* The test suite files all have the suffix `-test.xslt` and are in the `src/` directory alongside the code under test.
* Output is generated into a scratch directory named `build/testing`.
* There is a single root test suite, named `all-tests.xslt`, that imports all the other test suites in the test directory.