hi, is there a way to do deep comparison of two ob...
# test
l
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
I don't think reflection allows doing this in non-JVM platforms
If your objects can be
@Serializable
there may be other options
l
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
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
👍 1