https://kotlinlang.org logo
Title
n

Neel Kamath

06/19/2020, 3:35 AM
I currently get extremely long lines when a
dataClass1 shouldBe dataClass2
test fails. Is there any way it could be pretty printed so that I needn't spend minutes manually formatting it every time to see the diff? I think I saw Gradle pretty print a
List
or something I had once. Sorry if this is unrelated to Kotest. I'm unsure whether this is issue is from Kotest, Gradle, JUnit, etc.
l

LeoColman

06/19/2020, 4:46 AM
I believe this is related to https://github.com/kotest/kotest/issues/826
It was included in 4.1.0.RC2, could you take a look?
n

Neel Kamath

06/19/2020, 6:10 AM
I tried it out. It works if the same data class is being compared (e.g.,
MyClass shouldBe MyClass
). It doesn't work for collections of data classes (e.g.,
listOf(MyClass1, MyClass2) shouldBe listOf(MyClass1, MyClass2)
. It doesn't work for different data classes (e.g.,
MyClass1
shouldBe
MyClass2
). Obviously, comparing different data classes would always fail the test. However, I believe this is still an issue because Kotest still allows it to compile, and the reader of the test report doesn't know it's a different data class until it's been somewhat formatted.
s

sam

06/19/2020, 8:03 PM
We can inprove the error if the classes are not equal