Shalom Halbert
11/27/2021, 10:25 PMEither<Exception, Any>
with left
equal to a caught Exception
is equal to an expected value?simon.vergauwen
11/27/2021, 10:45 PMsimon.vergauwen
11/27/2021, 10:47 PMfun doSomething() = IllegalAccessException().left()
@Test
fun sample() {
val actual = doSomething()
actual.shouldBeLeft().shouldBeTypeOf<IllegalAccessException>
}
simon.vergauwen
11/27/2021, 10:49 PMassert(actual == expected)
Since Either
is implemented as a data class
, the problem here is that Throwable
is not comparable.
Every constructed Throwable
has an unique StackTrace
and are thus not equal.simon.vergauwen
11/27/2021, 10:49 PMassert(RuntimeExeception() != RuntimeExeception())
Shalom Halbert
11/27/2021, 11:35 PMShalom Halbert
11/28/2021, 3:37 AMshouldBeLeft()
is a broken assertion. Added an issue about it:
https://github.com/kotest/kotest-extensions-arrow/issues/99simon.vergauwen
11/28/2021, 2:29 PMShalom Halbert
11/28/2021, 3:56 PM