On 2015-01-05, Stefan Bodewig wrote: >> ------------- >> Diff & DiffBuilder. >> ------------- >> I'm now finished with Diff & DiffBuilder.
> I'll try to have a look and provide feedback soon. What I had in mind is slightly different, but not much. Let me explain what I would have done differently and we can then figure out together what seems to be the best. * Comparison is not good enough to capture a difference as the ComparisonResult is missing. So Diff should use a (new) class containing Comparison and outcome. * I hadn't thought of ComparisonFormatter but your IDE example is an intriguing one. My choice would be to have a toString method with a ComparisonFormatter argument rather than an instance variable. The no-arg toString would always use the default fomatter and ComparisonMatcher could pass in a different one when needed. * nit-pick I'd use Iterable rather than List as return value * I'd likely remove Diff#getFirstDifference completely * there can only be one DifferenceEvaluator, so the var-args versions are not needed - we may want to have a var-args withDifferenceListeners in DiffBuilder * DiffBuilder may want an option to short-cut the comparison as soon as the outcome is clear. I.e. return CRITICAL from the DifferenceEvaluator as soon as a DIFFERNT (or potentially a SIMILAR) result has been received. * my design would have ComparisonMatcher be a Matcher<Diff> and force people to create the Diff using DiffBuilder Diff diffResult = DiffBuilder... assertThat(diffResult, DiffMatcher.isSimilar()); that way we didn't have to duplicate ignoreWhitespace and friends in two or three builders. Maybe have a DiffMatcher and a ComparisonMatcher as separate classes with ComparisonMatcher being Matcher<Source>? This would also reduce the need for Input.fromUnknown. * DiffBuilder should be in the builder package While writing this list I've come to realize the DifferenceEvaluator contract is probably wrong. In order to short-cut a comparison it has to modify the comparison result. This likely means we need something akin to ComparisonController of 1.x. WDYT? Stefan ------------------------------------------------------------------------------ Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net _______________________________________________ Xmlunit-general mailing list Xmlunit-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xmlunit-general