package strikt.api

Classes

Name Description
interface Assertion: Any

Allows assertion implementations to determine a result.

interface AtomicAssertion: Assertion, Any

An assertion of a single condition on a subject.

interface CompoundAssertion: Assertion, Any

An assertion composed of multiple conditions whose overall result is determined by some aggregation of those conditions' results.

interface CompoundAssertions<T> : Any

Returned by Assertion.Builder.compose allowing a bridge between evaluation of composed assertions and the determination of the overall result in the block parameter passed to then.

interface DescribeableBuilder<T> : Builder<T>, Any

Extension of Assertion.Builder that enables the description of the assertion subject.

Since it doesn't make sense to do this anywhere except directly after the initial expectThat or Assertion.Builder.with call those methods return an instance of this interface, while assertions themselves just return Assertion.Builder.

interface ExpectationBuilder: Any

Receiver for expect providing functions that define assertion subjects and create assertion chains or blocks.

Methods

expect

fun expect(block: suspend ExpectationBuilder.()->Unit)

Starts a block of assertions that will all be evaluated regardless of whether earlier ones fail. This is the entry-point for the assertion API.

Parameters

Name Description
block: suspend ExpectationBuilder.()->Unit

ReturnValue

Name Description
Unit

expectThat

fun <T> expectThat(subject: T): DescribeableBuilder<T>

Start a chain of assertions over subject. This is the entry-point for the assertion API.

Parameters

Name Description
subject: T

the subject of the chain of assertions.

ReturnValue

Name Description
DescribeableBuilder<T>

an assertion for subject.

expectThat

fun <T> expectThat(subject: T, block: Builder<T>.()->Unit)

Evaluate a block of assertions over subject. This is the entry-point for the assertion API.

Parameters

Name Description
subject: T

the subject of the block of assertions.

block: Builder<T>.()->Unit

a closure that can perform multiple assertions that will all be evaluated regardless of whether preceding ones pass or fail.

ReturnValue

Name Description
Unit

an assertion for subject.

expectThrows

inline fun <E : Throwable> expectThrows(noinline action: suspend ()->Any?): Builder<E>

Asserts that actionthrows an exception of type E when executed.

Parameters

Name Description
noinline action: suspend ()->Any?

ReturnValue

Name Description
Builder<E>

an assertion over the thrown exception, allowing further assertions about messages, root causes, etc.

expectCatching

fun <T> expectCatching(action: suspend ()->T): DescribeableBuilder<Result<T>>

Start a chain of assertions over the result of action which may either be the value action returns or any exception it throws. This is the entry-point for the assertion API.

Parameters

Name Description
action: suspend ()->T

ReturnValue

Name Description
DescribeableBuilder<Result<T>>

an assertion for the successful or failed result of action.