XmlUnit

Here are a couple of wrapper methods that illustrate the use of XmlUnit in a test. You can get the same sample code online, but just for my own purposes, here it is.


private DetailedDiff diffDetailed(Object want, final String got)
throws SAXException, IOException {

return new DetailedDiff(new Diff(want.toString(),got));
}

private DetailedDiff diffSkeleton(Object want, final String got)
throws SAXException, IOException {

DifferenceListener myDifferenceListener = new IgnoreTextAndAttributeValuesDifferenceListener();
DetailedDiff diff = new DetailedDiff(new Diff(want.toString(),got));
diff.overrideDifferenceListener(myDifferenceListener);
return diff;
}

...
final DetailedDiff diff = diffSkeleton(expected, got);

assertTrue(diff.toString(),diff.similar());
...

Advertisements

Leave a comment

Filed under utility

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s