Package-level declarations

Types

Link copied to clipboard
interface AssertionScope

The scope in which assertions are executed.

Link copied to clipboard
fun interface Expect<out Value>

A type representing a value under assertion.

Link copied to clipboard

Functions

Link copied to clipboard
@JvmName(name = "assertContextual")
context(assertionScope: AssertionScope)
inline fun assert(checker: () -> AssertionScope.Assertion)

Executes the given assertion checker within the current assertion scope.

Link copied to clipboard
context(assertionScope: AssertionScope)
inline fun <Value> Expect<Value>.assert(checker: (Value) -> AssertionScope.Assertion)

Executes the given assertion checker on the value exposed by this Expect instance.

Executes the given assertion checker and consumes its result.

Link copied to clipboard
@JvmName(name = "failContextual")
context(assertionScope: AssertionScope)
fun fail(message: String, cause: Throwable? = null)

Fails the current assertion scope with the given message and optional cause.

Link copied to clipboard
fun AssertionScope.fail(message: String, cause: Throwable? = null)

Fails the current assertion scope with the given message and optional cause.

Link copied to clipboard
@JvmName(name = "softlyContextual")
context(assertionScope: AssertionScope)
inline fun firmly(block: context(AssertionScope) () -> Unit)
Link copied to clipboard
inline fun AssertionScope.firmly(block: context(AssertionScope) () -> Unit)
Link copied to clipboard
inline operator fun AssertionScope.invoke(block: context(AssertionScope) () -> Unit)

Invokes the given assertion block with this AssertionScope as the context receiver.

Link copied to clipboard
context(assertionScope: AssertionScope)
infix fun Expect<Any?>.notToBe(expected: Any?)

Asserts that the exposed value is not equal to the expected value using == comparison.

Link copied to clipboard
context(assertionScope: AssertionScope)
infix fun Expect<Any?>.notToBeTheSameInstanceAs(expected: Any?)

Asserts that the exposed value is not the same instance as the expected value using !== comparison.

Link copied to clipboard
context(assertionScope: AssertionScope)
inline fun Expect.Companion.notToThrow(crossinline block: () -> Unit)

Asserts that the given block does not throw any exception.

context(assertionScope: AssertionScope)
inline fun <Result> Expect.Companion.notToThrow(crossinline block: () -> Result, checker: Expect<Result>.() -> Unit)

Asserts that the given block does not throw any exception, and if it succeeds, asserts on the result using the provided checker.

Link copied to clipboard
infix fun <Value> Expect.Companion.of(value: Value): Expect<Value>

Creates an Expect assertion for the given value.

inline fun <Value> Expect.Companion.of(value: Value, block: Expect<Value>.() -> Unit)

Creates an Expect assertion for the given value and executes the assertion block on it.

Link copied to clipboard
infix fun <Value> Expect.Companion.ofLazy(provider: () -> Value): Expect<Value>

Creates an Expect assertion using a lazily-evaluated value provider function.

inline fun <Value> Expect.Companion.ofLazy(noinline provider: () -> Value, block: Expect<Value>.() -> Unit)

Creates an Expect assertion using a lazily-evaluated value provider function and executes the assertion block on it.

Link copied to clipboard
@JvmName(name = "softlyContextual")
context(assertionScope: AssertionScope)
inline fun softly(block: context(AssertionScope) () -> Unit)

Executes the given assertion block in a "soft" mode within the current assertion scope.

Link copied to clipboard
inline fun AssertionScope.softly(block: context(AssertionScope) () -> Unit)

Executes the given assertion block in a "soft" mode, collecting all assertion failures and reporting them together at the end.

Link copied to clipboard
context(assertionScope: AssertionScope)
infix fun Expect<Any?>.toBe(expected: Any?)

Asserts that the exposed value is equal to the expected value using == comparison.

Link copied to clipboard
context(assertionScope: AssertionScope)
infix fun <Element : Comparable<Element>> Expect<Element>.toBeGreaterThan(expected: Element)

Asserts that the exposed value is greater than the expected value.

Link copied to clipboard
context(assertionScope: AssertionScope)
infix fun <Element : Comparable<Element>> Expect<Element>.toBeGreaterThanOrEqualTo(expected: Element)

Asserts that the exposed value is greater than or equal to the expected value.

Link copied to clipboard
context(assertionScope: AssertionScope)
infix fun <Element : Comparable<Element>> Expect<Element>.toBeLessThan(expected: Element)

Asserts that the exposed value is less than the expected value.

Link copied to clipboard
context(assertionScope: AssertionScope)
infix fun <Element : Comparable<Element>> Expect<Element>.toBeLessThanOrEqualTo(expected: Element)

Asserts that the exposed value is less than or equal to the expected value.

Link copied to clipboard
context(assertionScope: AssertionScope)
infix fun Expect<Any?>.toBeTheSameInstanceAs(expected: Any?)

Asserts that the exposed value is the same instance as the expected value using === comparison.

Link copied to clipboard
context(assertionScope: AssertionScope)
inline fun Expect.Companion.toThrow(crossinline block: () -> Unit)

Asserts that the given block throws an exception.

@JvmName(name = "orThrowCheckingType")
context(assertionScope: AssertionScope)
inline fun <ThrowableType : Throwable> Expect.Companion.toThrow(crossinline block: () -> Unit)

Asserts that the given block throws an exception of the specified type ThrowableType.

@JvmName(name = "orThrowCheckingType")
context(assertionScope: AssertionScope)
inline fun <ThrowableType : Throwable> Expect.Companion.toThrow(crossinline block: () -> Unit, checker: Expect<ThrowableType>.() -> Unit)

Asserts that the given block throws an exception of the specified type ThrowableType, and if it does, asserts on the thrown exception using the provided checker.

context(assertionScope: AssertionScope)
inline fun Expect.Companion.toThrow(crossinline block: () -> Unit, checker: Expect<Throwable>.() -> Unit)

Asserts that the given block throws an exception, and if it does, asserts on the thrown exception using the provided checker.

Link copied to clipboard
infix fun <Value> Expect.Companion.using(provider: () -> Value): Expect<Value>

Creates an Expect assertion using a value provider function.

Transforms an Expect assertion from one value type to another using a provider function.

inline fun <Value> Expect.Companion.using(noinline provider: () -> Value, block: Expect<Value>.() -> Unit)

Creates an Expect assertion using a value provider function and executes the assertion block on it.

inline fun <OldValue, NewValue> Expect<OldValue>.using(noinline provider: (OldValue) -> NewValue, block: Expect<NewValue>.() -> Unit)

Transforms an Expect assertion from one value type to another using a provider function and executes the assertion block on the transformed value.

Link copied to clipboard

Transforms an Expect assertion from one value type to another using a lazily-evaluated provider function.

inline fun <OldValue, NewValue> Expect<OldValue>.usingLazily(noinline provider: (OldValue) -> NewValue, block: Expect<NewValue>.() -> Unit)

Transforms an Expect assertion from one value type to another using a lazily-evaluated provider function and executes the assertion block on the transformed value.

Link copied to clipboard
@JvmName(name = "withClueContextual")
context(assertionScope: AssertionScope)
inline fun withClue(crossinline clue: () -> String, block: context(AssertionScope) () -> Unit)

Executes the given assertion block with a lazily-evaluated clue that is prefixed to any assertion failure messages within the current assertion scope.

@JvmName(name = "withClueContextual")
context(assertionScope: AssertionScope)
inline fun withClue(clue: String, block: context(AssertionScope) () -> Unit)

Executes the given assertion block with a descriptive clue that is prefixed to any assertion failure messages within the current assertion scope.

Link copied to clipboard
inline fun AssertionScope.withClue(crossinline clue: () -> String, block: context(AssertionScope) () -> Unit)

Executes the given assertion block with a lazily-evaluated clue that is prefixed to any assertion failure messages.

inline fun AssertionScope.withClue(clue: String, block: context(AssertionScope) () -> Unit)

Executes the given assertion block with a descriptive clue that is prefixed to any assertion failure messages.