hi, is there a way to do deep comparison of two objects(of non data classes) in commonTest (something equivalent of
assertReflectionEquals
in java), i found
shouldBeEqualToComparingFields
in kotest assertions module but that is also jvm only.
c
CLOVIS
07/11/2025, 12:21 PM
I don't think reflection allows doing this in non-JVM platforms
CLOVIS
07/11/2025, 12:21 PM
If your objects can be
@Serializable
there may be other options
l
Luv Kumar
07/11/2025, 12:57 PM
yeah i had thought of
@serializable
but objects are unfortunately not
@serializable
, even if outer object is somehow serializable, inner nested objects also will have to be for that to work properly.
Yes reflection doesn't work well on non jvm but i was hoping if there is some multiplatform solution similar to it.
Use case: While writing tests we tend to equate full objects rather than just changed fields, to eradicate any side effects which could be caused by change of expected fields.
e
ephemient
07/11/2025, 2:19 PM
you could write an annotation processor which generates some
mostlyEquals
extension function or whatever you want to call it, but there's nothing built in