-
[OPIK-7706] [DOCS] docs: document AssertJ whole-object assertion conventions (#7698)
发布于
2026-08-03 14:40:49 +00:00 - [OPIK-7706] [DOCS] docs: document AssertJ whole-object assertion conventions
Field-by-field object comparison in backend tests goes stale invisibly:
adding a field to a record leaves the test passing while no longer
covering it. Document usingRecursiveComparison as the default, with
ignoringFields for deliberate partial comparisons so exclusions stay
reviewable, comparators instead of exclusions for BigDecimal/double, and
containsExactly for collections.Examples are lifted from real usage in the repo (StatsUtils comparators,
EXPERIMENT_IGNORED_FIELDS) rather than written fresh.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
- docs(testing): make plain isEqualTo the default over recursive comparison
Review feedback: equals/hashCode are the source of truth for equality in
Java, so recursive comparison is for exceptional cases only (excluding
fields, custom comparators, types with no usable equals) rather than the
default. Our API models are overwhelmingly records, whose generated
equals already picks up new components.Adds the JSON-views caveat so readers know existing bare
usingRecursiveComparison calls aren't the pattern to copy, and reframes
the comparator section as an exceptional case rather than an
ignore-vs-comparator choice.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
- docs(testing): caveat that containsExactly compares by element equals
The collections example contradicted the inexact-types guidance: it
offered containsExactlyInAnyOrderElementsOf as the order-insensitive
default, but that compares elements with the element type's own equals,
so BigDecimal/double fields stay brittle when numeric scale differs.Documents usingRecursiveFieldByFieldElementComparator(config) for that
case, framed as the same escalation rule as for single objects rather
than a competing one. Only 25 of 614 api model files touch BigDecimal,
so plain containsExactly* remains the default.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Co-authored-by: Claude Opus 5 (1M context) noreply@anthropic.com
下载附件