https://kotlinlang.org logo
#kotest
Title
# kotest
m

mitch

03/30/2022, 5:54 AM
question @sam a co-worker of mine just ran into a problem like below
Copy code
test("should print out failing inputs and shrinks when a function throws") {
      suspend fun functionThatUnexpectedlyThrows() { throw RuntimeException("aaaa") }
      checkAll(Arb.bigInt(4, 4)) { value ->
         functionThatUnexpectedlyThrows()
      }
   }
and then I realized that we don’t report the inputs or attempt any shrinking to the users when the exception is not kotest’s assertion errs. i.e.
Copy code
Property failed after 1 attempts
java.lang.AssertionError: Property failed after 1 attempts

Repeat this test by using seed 320358835705021305

Caused by RuntimeException: aaaa
if that function was wrapped around
shouldNotThrowAny { .. }
then that’ll print out the inputs and properly shrunk it. it’s written here https://github.com/kotest/kotest/blob/aba6984d6a08530e931274f7a9f6e3b62a66b681/kot[…]perty/src/commonMain/kotlin/io/kotest/property/internal/test.kt is this by design? or should we fix that? if you reckon that’s a bug i can raise an issue and raise a fix PR?
s

sam

03/30/2022, 6:13 AM
I'll check when back from vaca
👍 1
5 Views