- Comparing two xmls using XmlUnit 2.2.1 in java.
- The only difference between the documents is in the namespace prefix.
Here is code snippet to reproduce:
@Test
public void testDifferentPrefix() {
final String control = "<ns:a xmlns:ns='abc'><b attr=\"xyz\"></b></ns:a>";
final String test = "<ns1:a xmlns:ns1='abc'><b attr=\"xyz\"></b></ns1:a>";
Diff myDiff = DiffBuilder.compare(Input.fromString(control))
.withTest(Input.fromString(test))
.build();
Assert.assertFalse(myDiff.toString(), myDiff.hasDifferences());
}
when the above test is run, it is failing with below error:
Expected namespace prefix 'ns' but was 'ns1' - comparing at /pfx:a[1] to at /pfx:a[1] junit.framework.AssertionFailedError at NewEmptyJUnitTest.testDifferentPrefix(NewEmptyJUnitTest.java:95)
What should be corrected in order to avoid the error? I believe that am missing something trivial.