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

Adam S

04/20/2021, 6:25 PM
Hi 👋 If I’ve got a String Arb and I set the minimum size to 1, how can I stop it shrinking to size 0? In this example,
authKey
shrinks to 0, and so gives an invalid reason for failure.
Copy code
test("expect 'actual code is failing', _not_ authKey length error") {
    checkAll(
      Arb.string(1..10, Arb.alphanumeric()),
    ) {
        authKey,
      ->
      withClue("authKey must have length > 0") {
        authKey shouldHaveMinLength 1
      }
      fail("actual code is failing")
    }
  }
I’ve tried using
Arb.string(1..10, Arb.alphanumeric()).filter { it.isEmpty() },
but then the test loops endlessly
s

sam

04/20/2021, 6:38 PM
the shrinker doesn't take into account sizes
Can you file a bug on github and we'll push out a fix
👌 1
a

Adam S

04/20/2021, 6:41 PM
5 Views