java - How to catch AssertPathsEqual and print error to console? -
How can I catch this AssertionFailedError and print a message to the console that says:
I'm not sure how to capture values from values without having" hacked "and parse individual output strings manually. I have a great method rather than the "hack" method.
junit.framework.AssertionFailedError: org.custommonkey.xmlunit.Diff [different] expected text value '55555' but '55556' - comparison & lt; Region ... & gt; 55555 & lt; / Field & gt; On / xpathResult [1] / results [2] / field [1] / field [1] / field [6] / text () [1] to
I'm going to write my own Diff Deutscher class which parses the Diff text output?
You can catch AssertionError to get detailed error messages in the console.
You can try something like this:
try {// say that you are comparing fileReader objects which say // XML documents XMLEqual (filereader1, filereader2); } Hold (last SAXException e) {// show faiulre message} hold (last IOException e) {// show failure message} hold (Final AssertionError e) {System.err.println (e.toString ()); }
But I think getting more details about failure failure, by using error "square" def "(from org.custommonkey.xmlunit) instead of catching the apprehension better You can check whether the XML documents are compared to identical (or similar) and to get more information about the difference, using this class. You can get detailed DIF to get detailed Subdivision of DIF class Industry can be.
Documentation of Example 4 and Example probe 5 These examples show the use of Diff and Werthdif.
Comments
Post a Comment