Fail with full description for XML diff in XmlExpectationsHelper

Closes gh-33827
This commit is contained in:
boiarshinov
2024-10-31 13:44:39 +03:00
committed by Sam Brannen
parent dd92eac3ad
commit 91791c1756
2 changed files with 12 additions and 1 deletions

View File

@@ -74,4 +74,15 @@ class XmlExpectationsHelperTests {
.withMessageContaining("Expected child nodelist length '3' but was '2'");
}
@Test
void assertXmlEqualExceptionWithFullDescription() {
String control = "<root><field1>f1</field1><field2>f2</field2></root>";
String test = "<root><field2>f2</field2><field3>f3</field3></root>";
XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
xmlHelper.assertXmlEqual(control, test))
.withMessageContaining("Expected child 'field1' but was 'null'")
.withMessageContaining("Expected child 'null' but was 'field3'");
}
}