You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In RecursiveComparisonAssert, the method isEqualTo is currently hard-coded to employ the ErrorMessageFactory ShouldBeEqualByComparingFieldByFieldRecursively:
if (!differences.isEmpty()) throwobjects.getFailures().failure(info, shouldBeEqualByComparingFieldByFieldRecursively(actual,
In practice, users may be interested in customizing the error message.
One real use case is when comparing two large JSON files (represented by a nested object of Maps and Lists). In such scenarios, due to the default message always printing the whole "actual" and "expected" values...
... the assertion failure message may flood the terminal buffer, resulting in unreadable outputs, which goes against AssertJ's philosophy of being ergonomic.
This is what I see in IntelliJ IDEA -- Note how the message has been automatically shortened (with <...>), so I can't actually read what's wrong:
java.lang.AssertionError:
Expecting actual:
{"eee"="ffff"},
{"dddd"="cccc", "bbbb"="aaaa"<...>ompared with the following comparators:
- java.lang.Double -> org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration$$Lambda$2878/0x0000000802a995a0@4bda79d2
- java.lang.Float -> org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration$$Lambda$2878/0x0000000802a995a0@2a22ff7b
- java.lang.Integer -> org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration$$Lambda$2878/0x0000000802a995a0@122b5f62
- java.lang.Long -> org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration$$Lambda$2878/0x0000000802a995a0@8120f15
- java.nio.file.Path -> lexicographic comparator (Path natural order)
- actual and expected objects and their fields were compared field by field recursively even if they were not of the same type, this allows for example to compare a Person to a PersonDto (call strictTypeChecking(true) to change that behavior).
- the introspection strategy used was: DefaultRecursiveComparisonIntrospectionStrategy
My terminal emulator also can't handle this much output, resulting in me only able to see the last few lines of this message.
When running this assertion in a CI environment, whenever it fails, the console log page would be unable to render properly in my browser due to the sheer amount of text.
The text was updated successfully, but these errors were encountered:
Feature summary
In
RecursiveComparisonAssert
, the methodisEqualTo
is currently hard-coded to employ the ErrorMessageFactoryShouldBeEqualByComparingFieldByFieldRecursively
:assertj/assertj-core/src/main/java/org/assertj/core/api/RecursiveComparisonAssert.java
Line 15 in 4b280c4
assertj/assertj-core/src/main/java/org/assertj/core/api/RecursiveComparisonAssert.java
Line 157 in 4b280c4
In practice, users may be interested in customizing the error message.
One real use case is when comparing two large JSON files (represented by a nested object of
Map
s andList
s). In such scenarios, due to the default message always printing the whole "actual" and "expected" values...assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldBeEqualByComparingFieldByFieldRecursively.java
Line 37 in 4b280c4
... the assertion failure message may flood the terminal buffer, resulting in unreadable outputs, which goes against AssertJ's philosophy of being ergonomic.
Example
This is what I see in IntelliJ IDEA -- Note how the message has been automatically shortened (with
<...>
), so I can't actually read what's wrong:My terminal emulator also can't handle this much output, resulting in me only able to see the last few lines of this message.
When running this assertion in a CI environment, whenever it fails, the console log page would be unable to render properly in my browser due to the sheer amount of text.
The text was updated successfully, but these errors were encountered: