Is there a best practice in comparing two different objects e.g. two Dtos and if they differ to not show a long result where it is difficult to find the property which differs if the object is somehow complex and nested?
Currently I see a long result where it is difficult or cumbersome to find which specific propery failed. At least it is using a data class using Kotlin.
And in the IDE e.g. IntelliJ you have to scroll to see the full comparision if the object is bigger or more complex. It is not intuitive or easy to find where the difference is.
What I want to avoid is e.g. to use assertions for every property and only check the properties against each other.
In my opinion this leads to a maintenance overhead.
For example I can see using Kotest this nice output. Why is this not possible with Junit5 assertEquals method?
org.opentest4j.AssertionFailedError: data class diff for com.lennykey.Cat
├ name: expected:<"Catta"> but was:<"Catty">
├ favouriteDish: expected:<"Tuna"> but was:<"Fish">
└ father: Expected null but actual was Cat(name=Father, color=orange, birthDay=1.01.1980, address=Street 1, favouriteDish=Fish, mother=null, father=null)
expected:<Cat(name=Catta, color=orange, birthDay=1.01.1980, address=Street 1, favouriteDish=Tuna, mother=null, father=null)> but was:<Cat(name=Catty, color=orange, birthDay=1.01.1980, address=Street 1, favouriteDish=Fish, mother=null, father=Cat(name=Father, color=orange, birthDay=1.01.1980, address=Street 1, favouriteDish=Fish, mother=null, father=null))>
Expected :Cat(name=Catta, color=orange, birthDay=1.01.1980, address=Street 1, favouriteDish=Tuna, mother=null, father=null)
Actual :Cat(name=Catty, color=orange, birthDay=1.01.1980, address=Street 1, favouriteDish=Fish, mother=null, father=Cat(name=Father, color=orange, birthDay=1.01.1980, address=Street 1, favouriteDish=Fish, mother=null, father=null))