Unit test XSL transformations
Mint will be a very XSL transformation heavy application. That is why I've been thinking alot about how to manage all the transformation code. Well let's start off with unit testing.
Unit testing XSLT?
Unit testing the transformation gives you the same benefits as unit testing any other code.
Regression testing, it will help you validate that the old stuff is still working while you add new functionality
It will help you structure your XSLT and write beautiful testable code
It will give you confidence about the stability of your code
How to unit test XSLT
There's already a whole language that will let you make sure that XML is valid. Since the result of my transformations will be XHTML I can use XML Schema to validate that the XSL script gave expected result.
Make sure that you split up your XSLT in templates so they will be easy to test.
Write one or more XML snippets for each of these templates.
Write XSD that defines what you expect after the snippet has been transformed
Write a unit test that will be the engine of transformation of the snippet, to validation of the result. In Mint I use the NUnit extensions RowTest, and define the XML snippet filename and XSD Schema filename as input parameters. The files I store as embedded resources in the unit test library.
From now on you have your XSL transformations properly unit tested.