That yields the following solution the the example...
# arrow
s
That yields the following solution the the example above
Copy code
fun doSomething() = IllegalAccessException("message").left()

    @Test
    fun sample() {
        doSomething().shouldBeLeftThrowableWithMessage<IllegalAccessException>("message")
    }
s
You can also compose
Kotest
asserstions.
Copy code
doSomething().shouldBeLeft().message shouldBe "message"
shouldBeLeft
uses smart-casting, and extracts the value out of
Either
after the assertions succeeds
So you have access to
Throwable
after
shouldBeLeft()
s
Based on the documentation, it seems like the intended way to make assertion on a
Left<Throwable>
is by using
Copy code
doSomething().shouldBeLeftOfType<IllegalAccessException>().message shouldBe "message"
s
Oh, didn’t know that one. Guess I’m still holding on to some of my old assertions-core habits from before this lib 😅
s
Hehe
Well, it seems like that assertion is documented on Kotest’s website, but it’s not in the source code 😅
s
Oh, I think that’s because it was deprecated in favor of composing existing assertions.
doSomething().shouldBeLeft().message shouldBe "message"
or
doSomething().shouldBeLeft().shouldBeOfType<IllegalAccessException>().message shouldBe "message"
1
Oh, that first one was broken. So yes, that has to be fixed in order for this change to makes sense IMO
s
Ends up I simply messed up by using the wrong version (1.0.1 instead of 1.1.1) 🤦
s
There's lots of improvements going into these extensions courtesy of @Imran/Malic
👏 2
i
Hope to start updating the docs @Shalom Halbert soon after 1.2.0 is published I was stuck on a compiler error from 1.5.30
Here is a small correction on the docs https://github.com/kotest/kotest/pull/2685
s
Merged
😄 1