public Gen<T>
A Generator, or interface Gen is responsible for generating data
to be used in property testing. Each generator will
generate data for a specific type .
The idea behind property testing is the testing framework will automatically test a range of different values, including edge cases and random values.
There are two types of values to consider.
The first are values that should always be included - those edge cases values which are common sources of bugs. For example, a generator for Ints should always include values like zero, minus 1, positive 1, Integer.MAX_VALUE and Integer.MIN_VALUE.
Another example would be for a generator for enums. That should include all the values of the enum to ensure each value is tested.
The second set of values are random values, which are used to give us a greater breadth of values tested. The Int generator example should return a random int from across the entire integer range.
interface Gen,
Int,
Int| Modifier and Type | Interface and Description |
|---|---|
static class |
Gen.Companion |
static class |
Gen.DefaultImpls
A Generator, or
interface Gen is responsible for generating data
to be used in property testing. Each generator will
generate data for a specific type . |
| Modifier and Type | Field and Description |
|---|---|
static Gen.Companion |
Companion |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Iterable<T> |
constants()
Returns the values that should always be used
if this generator is to give complete coverage.
|
Gen<T> |
filter(kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> pred)
Create a new
interface Gen by filtering the output of this gen. |
Gen<T> |
filterNot(kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> f) |
<U> Gen<U> |
flatMap(kotlin.jvm.functions.Function1<? super T,? extends io.kotlintest.properties.Gen<U>> f)
Create a new
interface Gen by mapping the output of this gen. |
<U> Gen<U> |
map(kotlin.jvm.functions.Function1<? super T,? extends U> f)
Create a new
interface Gen by mapping the output of this gen. |
<U extends T> |
merge(Gen<U> gen)
Returns a new [
interface Gen] which will return the values from this gen and the values of
the supplied gen together. The supplied gen must be a subtype of the
type of this gen. |
java.lang.String |
nextPrintableString(int length) |
Gen<T> |
orNull()
Create a new
interface Gen which will return the values of this gen plus null. |
kotlin.sequences.Sequence<T> |
random()
Generate a random sequence of type T, that is compatible
with the constraints of this generator.
|
Shrinker<T> |
shrinker() |
static Gen.Companion Companion
java.lang.Iterable<T> constants()
Returns the values that should always be used if this generator is to give complete coverage.
kotlin.sequences.Sequence<T> random()
Generate a random sequence of type T, that is compatible with the constraints of this generator.
Shrinker<T> shrinker()
Gen<T> filter(kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> pred)
Create a new interface Gen by filtering the output of this gen.
interface GenGen<T> filterNot(kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> f)
<U> Gen<U> flatMap(kotlin.jvm.functions.Function1<? super T,? extends io.kotlintest.properties.Gen<U>> f)
Create a new interface Gen by mapping the output of this gen.
interface Gen<U> Gen<U> map(kotlin.jvm.functions.Function1<? super T,? extends U> f)
Create a new interface Gen by mapping the output of this gen.
interface GenGen<T> orNull()
Create a new interface Gen which will return the values of this gen plus null.
interface Gen<U extends T> Gen<T> merge(Gen<U> gen)
Returns a new [interface Gen] which will return the values from this gen and the values of
the supplied gen together. The supplied gen must be a subtype of the
type of this gen.
interface Genjava.lang.String nextPrintableString(int length)