/// Saturday, April 15

XmlUnit

XMLUnit is a utility class to aid unit testing of XML processing. I've used it before but gave up on it too quickly mainly because it didn't ignore whitespace. I'm inundated with XML work. XMLUnit's differencing is too strict and is not very useful for me in its current state. So I downloaded the source, made it compliant with NUnit 2, modified a few unit tests so they run successfully from TestDriven.NET and finally added a property to ignore whitespace differences.

These two XML are now considered equal:

string control = "<a color=' red'><empty/>APPLE ORANGE</a>";
string test = "<a color=\"red\"><empty>        \t\r\n</empty>          APPLE   ORANGE          </a>";
XmlAssert.AreSimiliar(control, test);

Notice the library treats these as similiar (not identical):

I no longer have to worry about my xml editor reformatting my files and finding out later all my unit tests are broken. I'm considering starting a new project based on XMLUnit so I may enhance it and also rename methods to align it more closely with NUnit.

Comments:

Any plans to share the source for your updated XMLUnit?
 
You may have noticed that XMLUnit (Java) development has started again.

I plan to release XMLUnit Java 1.1 beta very soon and then focus on the .NET version. If you want to help out with your code changes, you are more than welcome.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?