truthish
truthish copied to clipboard
Add more clarity to issues where toString values are equal but the instances are not
One dev using Truthish pointed out you can write a test like this:
class Blah {
override fun toString(): String = ".base-style"
}
@Test
fun test() {
val blah = Blah()
assertThat(blah).isEqualTo(".base-style")
}
that generates a report like this:
Expected: ".base-style"
But was : .base-style
AssertionError: Two objects were not equal
We might want to detect if the toString output for the subject and the assertion value look the same and are different, and if so add extra info, maybe?
Imagine:
Expected: ".base-style" (type is `String`)
But was : .base-style (type is `Blah`)
AssertionError: Two objects were not equal
Are there any other edge cases we should be aware of?