From: Harald B. <bra...@gm...> - 2015-01-16 23:27:31
|
Hi, I have a few questions about the DifferenceEvaluators: >> But I think that one DifferenceEvaluator is not enough. >> At least DifferenceEvaluators.Default should always be part of, >> otherwise there is no ComparisonResult.SIMILAR. > >IMHO this is something the user of the API should take care of. If they >want to have DEFAULT's behaviour then they should include it explicitly. > You think, that the code should look like the following?: ---------- Diff myDiff = DiffBuilder.compare(control).withTest(test) .withDifferenceEvaluator(DifferenceEvaluators.first( DifferenceEvaluators.Default, new IgnoreAttributeDifferenceEvaluator("attr"))) .checkForSimilar() .build(); ---------- I think "checkForSimilar" will be the preferred method to compare two XMLs. But checkForSimilar() makes no sense without "DifferenceEvaluators.Default". On the other site I can't think of a situation where the "DifferenceEvaluators.Default" must be ignored to get a special goal? Even this rare cases could simply be handled with a method ".deactivateDefaultDifferenceEvaluator()" I checked in the UnitTest: https://github.com/brabenetz/xmlunit/commit/4a8e5eb676809344a6dbaf814289a6495db80728 >> But then I need a method like DifferenceEvaluators.inSequence(...) >> instead of DifferenceEvaluators.first(...). > >first() picks the first that changes the outcome, what would be the >result of inSequence()? > Simply passes the result to the next evaluator. Reason: The custom DifferenceEvaluator should also be triggered (e.g.: for Ignore) even if a Node was marked as "similar" before. And maybe the custom DifferenceEvaluator want to check if the Difference was "similar". >> I also think about a general SimpleIgnoreNodesDifferenceEvaluator >> (ignore some nodes) or a SimpleBigDecimalNodesDifferenceEvaluator >> (which evaluates "1" similar "1.00") implementations. > >The first one hints at the missing feature of ignoring parts completely. >I don't think DifferenceEvaluator is the best place for this. The >second one sounds like a third jar of xmlunit-library rather than -core? > Yes, it could be a third jar of xmlunit-library. What you mean with "DifferenceEvaluator is not the best place for this"? Is there another way? Thanks, Harald |