-
Notifications
You must be signed in to change notification settings - Fork 45
What is XSpec
XSpec is a unit test and Behaviour Driven Development (BDD) framework for XSLT and XQuery. It is based on the Spec framework of RSpec, which is a BDD framework for Ruby.
XSpec consists of a syntax for describing the behaviour of XSLT or XQuery code, and some code that enables to test code against those descriptions.
BDD is like Test Driven Development (TDD) in that it encourages to develop code by
- describing a behaviour (or writing a test)
- testing whether the code gives that behaviour
- if it doesn't, fixing the code until it does and the test passes
The difference between BDD and TDD is about how to write the tests. In BDD, the focus is on the behaviour of the code: the descriptions form the double role of both a human-readable documentation of what the code should do and runnable tests that can test whether the code does what it should do.
In BDD, the focus in on scenarios and the expected behaviour of the application with these scenarios. Scenarios fit particularly well with XSLT's source-driven (or template-driven) approach. For example, a scenario might be:
when processing a
paraelement, it should create apelement
or something more complex like:
when processing a
fnelement with alabelattribute infootnotemode,
it should create apelement with asupchild holding the value of thelabelattribute
Scenarios written like this naturally map onto XSLT templates.