Comparing attribute values

  • mxtthias

    mxtthias - 2010-04-06

    The following test fails:

    public void testDiffSimilar() throws Exception
    String a = "<a><b val=\"c\" /><b val=\"d\" /></a>";
    String b = "<a><b val=\"d\" /><b val=\"c\" /></a>";
    Diff diff = new Diff(a, b);

    What would I need to do to make the comparison work?

  • Stefan Bodewig

    Stefan Bodewig - 2010-04-07

    You need to help XMLUnit to determine which XML elements it should compare.  By default it will compare elements with the same element names in order.

    You want to specify a custom ElementQualifier - to be specific in your case you want to use a ElementNameAndAttributeQualifier.

  • mxtthias

    mxtthias - 2010-04-08

    Thanks! That solved my problem.


Log in to post a comment.