java - What is the idiomatic way for printing all the differences in XMLUnit? -


i'm trying override default xmlunit behavior of reporting first difference found between 2 inputs (text) report includes differences found.

i've far accomplished this:

private static void reportxhtmldifferences(string expected, string actual) {   diff ds = diffbuilder.compare(input.fromstring(expected))     .withtest(input.fromstring(actual))     .checkforsimilar()     .normalizewhitespace()     .ignorecomments()     .withdocumentbuilderfactory(dbf).build();    defaultcomparisonformatter formatter = new defaultcomparisonformatter();   if (ds.hasdifferences()) {     stringbuffer expectedbuffer = new stringbuffer();     stringbuffer actualbuffer = new stringbuffer();     (difference d: ds.getdifferences()) {       expectedbuffer.append(formatter.getdetails(d.getcomparison().getcontroldetails(), null, true));       expectedbuffer.append("\n----------\n");        actualbuffer.append(formatter.getdetails(d.getcomparison().gettestdetails(), null, true));       actualbuffer.append("\n----------\n");     }     throw new comparisonfailure("there html differences", expectedbuffer.tostring(), actualbuffer.tostring());   } } 

but don't like:

  1. having iterate through differences in client code.
  2. reaching internals of defaultcomparisonformatter , calling getdetails null comparisontype.
  3. concating differences line dashes.

maybe coming unjustified bad gut feeling, i'd know if has input on use case.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -