Skip to main content
Version: 2.x

Changing the Size of Sized Generators

To change the default size used by sized generators we can use size test aspect:

import zio._
import zio.test.{ test, _ }

test("generating small list of characters") {
check(Gen.small(Gen.listOfN(_)(Gen.alphaNumericChar))) { n =>
ZIO.attempt(n).debug *> Sized.size.map(s => assertTrue(s == 50))
}
} @@ TestAspect.size(50) @@ TestAspect.samples(5)

Sample output:

List(p, M)
List()
List(0, m, 5)
List(Y)
List(O, b, B, V)
+ generating small list of characters
Ran 1 test in 676 ms: 1 succeeded, 0 ignored, 0 failed

ZIO Chat

Hi there! 👋 I'm ZIO Chat, your friendly neighborhood ZIO expert. I'm here to help you navigate the world of ZIO. Whether you're a seasoned pro or just starting out, fire away with your ZIO questions. I will hit you back with the best insights I've got. Let's dive into the world of ZIO together!