Copilot commented on code in PR #3188:
URL:
https://github.com/apache/incubator-kie-optaplanner/pull/3188#discussion_r2660541781
##########
optaplanner-benchmark/src/test/java/org/optaplanner/benchmark/impl/result/PlannerBenchmarkResultTest.java:
##########
@@ -152,7 +152,11 @@ void xmlReportRemainsSameAfterReadWrite() throws
IOException {
String originalXml = IOUtils.toString(
PlannerBenchmarkResultTest.class.getResourceAsStream(TEST_PLANNER_BENCHMARK_RESULT),
StandardCharsets.UTF_8);
- assertThat(jaxbString.trim()).isXmlEqualTo(originalXml.trim());
+ org.xmlunit.assertj3.XmlAssert.assertThat(jaxbString)
+ .and(originalXml)
+ .ignoreWhitespace()
+ .ignoreChildNodesOrder()
+ .areSimilar();
Review Comment:
The XMLUnit assertion here uses `areSimilar()` which allows for some
differences in the XML structure. However, for a round-trip test that verifies
XML remains the same after read/write, consider using `areIdentical()` instead.
The `areSimilar()` method is more lenient and may not catch certain XML
serialization issues. If the intention is to be lenient about child node order
and whitespace but strict about everything else, `areIdentical()` combined with
the ignore options would be more appropriate.
```suggestion
.areIdentical();
```
##########
optaplanner-benchmark/src/test/java/org/optaplanner/benchmark/impl/result/PlannerBenchmarkResultTest.java:
##########
@@ -152,7 +152,11 @@ void xmlReportRemainsSameAfterReadWrite() throws
IOException {
String originalXml = IOUtils.toString(
PlannerBenchmarkResultTest.class.getResourceAsStream(TEST_PLANNER_BENCHMARK_RESULT),
StandardCharsets.UTF_8);
- assertThat(jaxbString.trim()).isXmlEqualTo(originalXml.trim());
+ org.xmlunit.assertj3.XmlAssert.assertThat(jaxbString)
+ .and(originalXml)
+ .ignoreWhitespace()
+ .ignoreChildNodesOrder()
+ .areSimilar();
Review Comment:
The same flaky test issue likely affects other similar XML round-trip tests
in the codebase. The test `xmlConfigFileRemainsSameAfterReadWrite` in
`PlannerBenchmarkConfigTest.java` also uses `isXmlEqualTo()` and may suffer
from the same non-deterministic behavior with child node ordering. Consider
applying the same XMLUnit fix to that test for consistency.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]