dr.dreigh
05/16/2020, 8:32 AMdata class diff for com.sksamuel.kotest.matchers.Baz
├ booFoo: data class diff for com.sksamuel.kotest.matchers.BooFoo
│ ├ a: expected:<9L> but was:<8L>
│ └ foo: data class diff for com.sksamuel.kotest.matchers.Foo
│ ├ a: expected:<123L> but was:<321L>
│ ├ b: expected:<"a"> but was:<"b">
│ └ c: expected:<"a"> but was:<"c">
├ i: expected:<66> but was:<67>
└ things: expected:<["cheese", 22]> but was:<["egg", 1]>
... however, it's lots of string manipulation. it uses shouldBe
to choose the correct Eq
instance. Then it gets the string from the the Throwable.message
, and if it's a nested data class it does a little more manipulation.
My only thoughts to make this a little cleaner would be to change the Eq
interface (and the instances), such that instead of returning a Throwable?
, it returns a type which contains the differences. That way we don't have string manipulate as we'd have access to the diff data. However this might complicate things for the purpose of one feature. Be good to get the thoughts of people a bit more familiar with the codebase, I'm sure there's a much simper way - I just don't can't see it! 🙈 (If you want to see my extremely hacky POC code for reference).sam
05/18/2020, 12:55 PMdr.dreigh
05/18/2020, 1:18 PMsam
05/20/2020, 1:10 PMAssertionError
which contains the error, the expected and the actual values.when (error) {
is org.opentest4j.AssertionFailedError ->
if (error.isActualDefined && error.isExpectedDefined) {
type("comparisonFailure")
.actual(error.actual.stringRepresentation)
.expected(error.expected.stringRepresentation)
}
}
AssertionFailedError
is the opentest4k's version of an error that contains actual and expecteddr.dreigh
05/20/2020, 7:59 PMsam
05/29/2020, 3:05 PMdr.dreigh
05/29/2020, 3:45 PMsam
05/29/2020, 3:54 PM