kotest-assertions / io.kotest.matchers / Matcher

Matcher

interface Matcher<T>

A Matcher is the main abstraction in the assertions library.

Implementations contain a single function, called 'test', which accepts a value of type T and returns an instance of MatcherResult. This MatcherResult return value contains the state of the assertion after it has been evaluted.

A matcher will typically be invoked when used with the should functions in the assertions DSL. For example, 2 should beLessThan(4)

Functions

and

open infix fun and(other: Matcher<T>): Matcher<T>

compose

open infix fun <U> compose(fn: (U) -> T): Matcher<U>

contramap

open fun <U> contramap(f: (U) -> T): Matcher<U>

invert

open fun invert(): Matcher<T>

or

open infix fun or(other: Matcher<T>): Matcher<T>

test

abstract fun test(value: T): MatcherResult