kotest-property / io.kotest.property

Package io.kotest.property

Types

Arb

An Arb (for arbitrary) is a provider of property test data in two categories: edgecases and samples.

abstract class Arb<A> : Gen<A>

Exhaustive

An exhaustive is a type of Gen which generates an exhaustive set of values from a defined range.

abstract class Exhaustive<A> : Gen<A>

Gen

A Gen is responsible for providing values to be used in property testing. You can think of it as like an input stream for values. Each arg will provide data for a specific type .

sealed class Gen<out A>

PropertyContext

A PropertyContext is used when executing a propery test. It allows feedback and tracking of the state of the property test.

class PropertyContext

PropertyTesting

Global object for containing settings for property testing.

object PropertyTesting

PropTestConfig

data class PropTestConfig

RandomSource

data class RandomSource

RTree

data class RTree<out A>

Sample

Contains a single generated value from a Gen and an RTree of lazily evaluated shrinks.

data class Sample<out A>

Shrinker

Given a value, T, this function returns reduced values to be used as candidates for shrinking.

interface Shrinker<A>

ShrinkingMode

sealed class ShrinkingMode

Extensions for External Classes

kotlin.Long

kotlin.random.Random

Functions

checkAll

suspend fun <A, B, C, D, E, F> checkAll(genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, genF: Gen<F>, property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit): PropertyContext
suspend fun <A, B, C, D, E, F> checkAll(config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, genF: Gen<F>, property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit): PropertyContext
suspend fun <A, B, C, D, E, F> checkAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, genF: Gen<F>, property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit): PropertyContext
suspend fun <A, B, C, D, E, F> checkAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, genF: Gen<F>, property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit): PropertyContext
suspend fun <A, B, C, D, E, F> checkAll(property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit): PropertyContext
suspend fun <A, B, C, D, E, F> checkAll(config: PropTestConfig, property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit): PropertyContext
suspend fun <A, B, C, D, E, F> checkAll(iterations: Int, property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit): PropertyContext
suspend fun <A, B, C, D, E, F> checkAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit): PropertyContext
suspend fun <A> Gen<A>.checkAll(property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> Gen<A>.checkAll(iterations: Int, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> checkAll(iterations: Int, genA: Gen<A>, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> Gen<A>.checkAll(config: PropTestConfig, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> checkAll(config: PropTestConfig, genA: Gen<A>, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> Gen<A>.checkAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> checkAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> checkAll(property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> checkAll(iterations: Int, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> checkAll(config: PropTestConfig, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> checkAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A, B> checkAll(genA: Gen<A>, genB: Gen<B>, property: suspend PropertyContext.(A, B) -> Unit): PropertyContext
suspend fun <A, B> checkAll(config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, property: suspend PropertyContext.(A, B) -> Unit): PropertyContext
suspend fun <A, B> checkAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, property: suspend PropertyContext.(A, B) -> Unit): PropertyContext
suspend fun <A, B> checkAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, property: suspend PropertyContext.(A, B) -> Unit): PropertyContext
suspend fun <A, B> checkAll(property: suspend PropertyContext.(A, B) -> Unit): PropertyContext
suspend fun <A, B> checkAll(config: PropTestConfig, property: suspend PropertyContext.(A, B) -> Unit): PropertyContext
suspend fun <A, B> checkAll(iterations: Int, property: suspend PropertyContext.(A, B) -> Unit): PropertyContext
suspend fun <A, B> checkAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A, B) -> Unit): PropertyContext
suspend fun <A, B, C> checkAll(genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, property: suspend PropertyContext.(A, B, C) -> Unit): PropertyContext
suspend fun <A, B, C> checkAll(config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, property: suspend PropertyContext.(A, B, C) -> Unit): PropertyContext
suspend fun <A, B, C> checkAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, property: suspend PropertyContext.(A, B, C) -> Unit): PropertyContext
suspend fun <A, B, C> checkAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, property: suspend PropertyContext.(A, B, C) -> Unit): PropertyContext
suspend fun <A, B, C> checkAll(property: suspend PropertyContext.(A, B, C) -> Unit): PropertyContext
suspend fun <A, B, C> checkAll(config: PropTestConfig, property: suspend PropertyContext.(A, B, C) -> Unit): PropertyContext
suspend fun <A, B, C> checkAll(iterations: Int, property: suspend PropertyContext.(A, B, C) -> Unit): PropertyContext
suspend fun <A, B, C> checkAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A, B, C) -> Unit): PropertyContext
suspend fun <A, B, C, D> checkAll(genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, property: suspend PropertyContext.(A, B, C, D) -> Unit): PropertyContext
suspend fun <A, B, C, D> checkAll(config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, property: suspend PropertyContext.(A, B, C, D) -> Unit): PropertyContext
suspend fun <A, B, C, D> checkAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, property: suspend PropertyContext.(A, B, C, D) -> Unit): PropertyContext
suspend fun <A, B, C, D> checkAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, property: suspend PropertyContext.(A, B, C, D) -> Unit): PropertyContext
suspend fun <A, B, C, D> checkAll(property: suspend PropertyContext.(A, B, C, D) -> Unit): PropertyContext
suspend fun <A, B, C, D> checkAll(config: PropTestConfig, property: suspend PropertyContext.(A, B, C, D) -> Unit): PropertyContext
suspend fun <A, B, C, D> checkAll(iterations: Int, property: suspend PropertyContext.(A, B, C, D) -> Unit): PropertyContext
suspend fun <A, B, C, D> checkAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A, B, C, D) -> Unit): PropertyContext
suspend fun <A, B, C, D, E> checkAll(genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, property: suspend PropertyContext.(A, B, C, D, E) -> Unit): PropertyContext
suspend fun <A, B, C, D, E> checkAll(config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, property: suspend PropertyContext.(A, B, C, D, E) -> Unit): PropertyContext
suspend fun <A, B, C, D, E> checkAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, property: suspend PropertyContext.(A, B, C, D, E) -> Unit): PropertyContext
suspend fun <A, B, C, D, E> checkAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, property: suspend PropertyContext.(A, B, C, D, E) -> Unit): PropertyContext
suspend fun <A, B, C, D, E> checkAll(property: suspend PropertyContext.(A, B, C, D, E) -> Unit): PropertyContext
suspend fun <A, B, C, D, E> checkAll(config: PropTestConfig, property: suspend PropertyContext.(A, B, C, D, E) -> Unit): PropertyContext
suspend fun <A, B, C, D, E> checkAll(iterations: Int, property: suspend PropertyContext.(A, B, C, D, E) -> Unit): PropertyContext
suspend fun <A, B, C, D, E> checkAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A, B, C, D, E) -> Unit): PropertyContext

checkCoverage

Asserts that the given label was applied to at least percentage number of tests. See PropertyContext.classify.

suspend fun checkCoverage(label: String, percentage: Double, f: suspend () -> PropertyContext): PropertyContext

Asserts more than one label coverage at once.

suspend fun checkCoverage(vararg pairs: Pair<String, Double>, f: suspend () -> PropertyContext): PropertyContext

forAll

suspend fun <A, B, C, D, E, F> forAll(genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, genF: Gen<F>, property: suspend PropertyContext.(A, B, C, D, E, F) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E, F> forAll(config: PropTestConfig = PropTestConfig(), genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, genF: Gen<F>, property: suspend PropertyContext.(A, B, C, D, E, F) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E, F> forAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, genF: Gen<F>, property: suspend PropertyContext.(A, B, C, D, E, F) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E, F> forAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, genF: Gen<F>, property: suspend PropertyContext.(A, B, C, D, E, F) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E, F> forAll(property: PropertyContext.(A, B, C, D, E, F) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E, F> forAll(config: PropTestConfig = PropTestConfig(), property: PropertyContext.(A, B, C, D, E, F) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E, F> forAll(iterations: Int, property: PropertyContext.(A, B, C, D, E, F) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E, F> forAll(iterations: Int, config: PropTestConfig, property: PropertyContext.(A, B, C, D, E, F) -> Boolean): PropertyContext
suspend fun <A> Gen<A>.forAll(property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> Gen<A>.forAll(iterations: Int, property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> forAll(iterations: Int, genA: Gen<A>, property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> Gen<A>.forAll(config: PropTestConfig, property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> forAll(config: PropTestConfig, genA: Gen<A>, property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> Gen<A>.forAll(iterations: Int, config: PropTestConfig, property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> forAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> forAll(property: suspend PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> forAll(iterations: Int, property: suspend PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> forAll(config: PropTestConfig, property: suspend PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> forAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A, B> forAll(genA: Gen<A>, genB: Gen<B>, property: suspend PropertyContext.(A, B) -> Boolean): PropertyContext
suspend fun <A, B> forAll(config: PropTestConfig = PropTestConfig(), genA: Gen<A>, genB: Gen<B>, property: suspend PropertyContext.(A, B) -> Boolean): PropertyContext
suspend fun <A, B> forAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, property: suspend PropertyContext.(A, B) -> Boolean): PropertyContext
suspend fun <A, B> forAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, property: suspend PropertyContext.(A, B) -> Boolean): PropertyContext
suspend fun <A, B> forAll(property: PropertyContext.(A, B) -> Boolean): PropertyContext
suspend fun <A, B> forAll(config: PropTestConfig = PropTestConfig(), property: PropertyContext.(A, B) -> Boolean): PropertyContext
suspend fun <A, B> forAll(iterations: Int, property: PropertyContext.(A, B) -> Boolean): PropertyContext
suspend fun <A, B> forAll(iterations: Int, config: PropTestConfig, property: PropertyContext.(A, B) -> Boolean): PropertyContext
suspend fun <A, B, C> forAll(genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, property: suspend PropertyContext.(A, B, C) -> Boolean): PropertyContext
suspend fun <A, B, C> forAll(config: PropTestConfig = PropTestConfig(), genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, property: suspend PropertyContext.(A, B, C) -> Boolean): PropertyContext
suspend fun <A, B, C> forAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, property: suspend PropertyContext.(A, B, C) -> Boolean): PropertyContext
suspend fun <A, B, C> forAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, property: suspend PropertyContext.(A, B, C) -> Boolean): PropertyContext
suspend fun <A, B, C> forAll(property: PropertyContext.(A, B, C) -> Boolean): PropertyContext
suspend fun <A, B, C> forAll(config: PropTestConfig = PropTestConfig(), property: PropertyContext.(A, B, C) -> Boolean): PropertyContext
suspend fun <A, B, C> forAll(iterations: Int, property: PropertyContext.(A, B, C) -> Boolean): PropertyContext
suspend fun <A, B, C> forAll(iterations: Int, config: PropTestConfig, property: PropertyContext.(A, B, C) -> Boolean): PropertyContext
suspend fun <A, B, C, D> forAll(genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, property: suspend PropertyContext.(A, B, C, D) -> Boolean): PropertyContext
suspend fun <A, B, C, D> forAll(config: PropTestConfig = PropTestConfig(), genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, property: suspend PropertyContext.(A, B, C, D) -> Boolean): PropertyContext
suspend fun <A, B, C, D> forAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, property: suspend PropertyContext.(A, B, C, D) -> Boolean): PropertyContext
suspend fun <A, B, C, D> forAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, property: suspend PropertyContext.(A, B, C, D) -> Boolean): PropertyContext
suspend fun <A, B, C, D> forAll(property: PropertyContext.(A, B, C, D) -> Boolean): PropertyContext
suspend fun <A, B, C, D> forAll(config: PropTestConfig = PropTestConfig(), property: PropertyContext.(A, B, C, D) -> Boolean): PropertyContext
suspend fun <A, B, C, D> forAll(iterations: Int, property: PropertyContext.(A, B, C, D) -> Boolean): PropertyContext
suspend fun <A, B, C, D> forAll(iterations: Int, config: PropTestConfig, property: PropertyContext.(A, B, C, D) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E> forAll(genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, property: suspend PropertyContext.(A, B, C, D, E) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E> forAll(config: PropTestConfig = PropTestConfig(), genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, property: suspend PropertyContext.(A, B, C, D, E) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E> forAll(iterations: Int, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, property: suspend PropertyContext.(A, B, C, D, E) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E> forAll(iterations: Int, config: PropTestConfig, genA: Gen<A>, genB: Gen<B>, genC: Gen<C>, genD: Gen<D>, genE: Gen<E>, property: suspend PropertyContext.(A, B, C, D, E) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E> forAll(property: PropertyContext.(A, B, C, D, E) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E> forAll(config: PropTestConfig = PropTestConfig(), property: PropertyContext.(A, B, C, D, E) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E> forAll(iterations: Int, property: PropertyContext.(A, B, C, D, E) -> Boolean): PropertyContext
suspend fun <A, B, C, D, E> forAll(iterations: Int, config: PropTestConfig, property: PropertyContext.(A, B, C, D, E) -> Boolean): PropertyContext

isEmpty

fun <A> RTree<A>.isEmpty(): Boolean

map

fun <A, B> RTree<A>.map(f: (A) -> B): RTree<B>

rtree

Generates an RTree of all shrinks from an initial value.

fun <A> Shrinker<A>.rtree(a: A): RTree<A>

sampleOf

fun <A> sampleOf(a: A, shrinker: Shrinker<A>): Sample<A>