Skip to content

Conversation

@Boiarshinov
Copy link
Contributor

@Boiarshinov Boiarshinov commented Oct 31, 2024

Only first difference is printed in assertion error when xml comparison is failed.
For example comparison of two xmls:

<root><a>a</a><b>b</b></root>

and

<root><b>b</b><c>c</c></root>

fails with message Body content Expected child 'a' but was 'null' - comparing <a...> at /root[1]/a[1] to <NULL>. There is nothing about child c in this message.

That is a strange behaviour of a xml-unit and it was updated with xmlunit/xmlunit#232

To fail with full diff description we should use fullDescription() method instead of toString() on Diff class.

With the full description fail message would be:

Body content Expected child 'a' but was 'null' - comparing <a...> at /root[1]/a[1] to <NULL>
Expected child 'null' but was 'c' - comparing <NULL> to <c...> at /root[1]/c[1]

Full description is better for bug fixing.

@pivotal-cla
Copy link

@Boiarshinov Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@Boiarshinov Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 31, 2024
@sbrannen sbrannen changed the title Fail with full description on xml diff Fail with full description for XML diff in XmlExpectationsHelper Oct 31, 2024
@sbrannen sbrannen added in: test Issues in the test module type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 31, 2024
@sbrannen sbrannen added this to the 6.2.x milestone Oct 31, 2024
@sbrannen sbrannen self-assigned this Oct 31, 2024
@sbrannen sbrannen modified the milestones: 6.2.x, 6.2.0 Oct 31, 2024
@sbrannen sbrannen removed their assignment Nov 14, 2024
@sbrannen sbrannen modified the milestones: 6.2.x, 6.2.1 Nov 19, 2024
@sbrannen sbrannen self-assigned this Nov 19, 2024
@sbrannen sbrannen closed this in 91791c1 Nov 19, 2024
@sbrannen
Copy link
Member

This has been merged into 6.2.x and main, for inclusion in Spring Framework 6.2.1.

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: test Issues in the test module type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants