Hey everyone! is there any assertion which can un...
# kotest
s
Hey everyone! is there any assertion which can understand a mapped object is based on another class? Let's say I have:
val p = Person (name='Sam', age= 30)
and there is function that I want to test and returns 'mapped' version of Person, sth like:
val mp = MappedPerson(name, age, someotherParam)
mp shouldBeDerivedFrom* m
(*shouldBeDerivedFrom doesn't exist I'm just writing my thoughts)
I think this can be helpful in layered architecture tests. Any idea?
a
there’s
shouldBeEqualToComparingFields
which uses reflection and thus requires JVM but you could always create your own utility function, which is usually what I prefer - it’s a bit more work but it tends to be more understandable and works better in practice
Copy code
infix fun Person.shouldBeMappedTo(mp: MappedPerson) { TODO() }
s
Thanks Adam I like the idea of creating my own functions for domain objects