In package strikt.api

class strikt.api.DescribeableBuilder

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.get call those methods return an instance of this interface, while assertions themselves just return Assertion.Builder.

Methods

abstract fun describedAs(description: String): Builder

Adds a description to the assertion.

Parameters:
  • description: String

    a description of the subject of the assertion. The description may include a String.format style placeholder for the value itself.

Extensions

fun <T> Builder.isNull(): Builder

Asserts that the subject is null.

Parameters:
  • No parameters
fun <T> Builder.isNotNull(): Builder

Asserts that the subject is not null.

Parameters:
  • No parameters
inline fun <T> Builder.isA(): Builder

Asserts that the subject is an instance of T.

Parameters:
  • No parameters
fun <T> Builder.isEqualTo(expected: T?): Builder

Asserts that the subject is equal to expected according to the standard Kotlin == operator.

Parameters:
  • expected: T?

    the expected value.

fun <T> Builder.isNotEqualTo(expected: T?): Builder

Asserts that the subject is not equal to expected according to the standard Kotlin == operator.

Parameters:
  • expected: T?

    the expected value.

fun <T> Builder.isSameInstanceAs(expected: Any?): Builder

Asserts that the subject is the same instance as expected according to the standard Kotlin === operator.

Parameters:
  • expected: Any?

    the expected instance.

fun <T> Builder.isNotSameInstanceAs(expected: Any?): Builder

Asserts that the subject is not the same instance as expected according to the standard Kotlin === operator.

Parameters:
  • expected: Any?

    the expected instance.

fun <T : Any> Builder.propertiesAreEqualTo(other: T): Builder

Asserts that all properties of the subject match those of other according to either contentEquals in the case of array properties or isEqualTo in other cases.

Properties are identified using Java beans conventions.

Parameters:
  • other: T
fun <T : Boolean?> Builder.isTrue(): Builder

Asserts that the subject is not null and is the boolean value true.

Parameters:
  • No parameters
fun <T : Boolean?> Builder.isFalse(): Builder

Asserts that the subject is not null and is the boolean value false.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.hasLength(expected: Int): Builder

Asserts that the subject has a CharSequence.length of exactly expected.

Parameters:
  • expected: Int
fun <T : CharSequence> Builder.isLowerCase(): Builder

Asserts that the subject is composed of all lower-case characters.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.isUpperCase(): Builder

Asserts that the subject is composed of all upper-case characters.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.startsWith(expected: Char): Builder

Asserts that the subject starts with the expected character.

Parameters:
  • expected: Char
fun <T : CharSequence> Builder.startsWith(expected: CharSequence): Builder

Asserts that the subject starts with the expected string.

Parameters:
  • expected: CharSequence
fun <T : CharSequence> Builder.endsWith(expected: CharSequence): Builder

Asserts that the subject ends with the expected string.

Parameters:
  • expected: CharSequence
fun <T : CharSequence> Builder.matches(expected: ): Builder

Asserts that the subject is a full match for the expected regular expression.

Parameters:
  • expected:
fun <T : CharSequence> Builder.matchesIgnoringCase(expected: ): Builder

Asserts that the subject is a full match for the expected regular expression regardless of case.

Parameters:
  • expected:
fun <T : CharSequence> Builder.contains(expected: ): Builder

Asserts that the subject contains a match for the expected regular expression.

Parameters:
  • expected:
fun <T : CharSequence> Builder.contains(expected: CharSequence): Builder

Asserts that the subject contains the expected substring.

Parameters:
  • expected: CharSequence
fun <T : E, E> Builder.contains(elements: E): Builder

Asserts that all elements are present in the subject. The elements may exist in any order any number of times and the subject may contain further elements that were not specified. If either the subject or elements are empty the assertion always fails.

Parameters:
  • elements: E
fun <T : E, E> Builder.contains(elements: Collection): Builder

Asserts that all elements are present in the subject. The elements may exist in any order any number of times and the subject may contain further elements that were not specified. If either the subject or elements are empty the assertion always fails.

Parameters:
  • elements: Collection
fun <T : CharSequence> Builder.containsIgnoringCase(expected: ): Builder

Asserts that the subject contains a match for the expected regular expression regardless of case.

Parameters:
  • expected:
fun <T : CharSequence> Builder.containsIgnoringCase(expected: CharSequence): Builder

Asserts that the subject contains the expected substring regardless of case.

Parameters:
  • expected: CharSequence
fun <T : CharSequence?> Builder.isNullOrEmpty(): Builder

Asserts that the subject is null or the empty string.

Parameters:
  • No parameters
fun <T : CharSequence?> Builder.isNullOrBlank(): Builder

Asserts that the subject is null, empty, or contains only whitespace characters.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.isBlank(): Builder

Asserts that the subject is empty, or contains only whitespace characters.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.isNotBlank(): Builder

Asserts that the subject is not blank (contains at least one non-whitespace character).

Parameters:
  • No parameters
fun <T : CharSequence> Builder.trim(): Builder

Trims the subject CharSequence.

Parameters:
  • No parameters
fun <T : E, E> Builder.isSorted(comparator: ): Builder

Asserts that the subject collection is sorted according to the Comparator. Empty collections are considered sorted.

Parameters:
  • comparator:
fun <T : T> Builder.isGreaterThan(expected: T): Builder

Asserts that the subject compares greater than expected according to Kotlin's standard > operator.

Parameters:
  • expected: T
fun <T : T> Builder.isLessThan(expected: T): Builder

Asserts that the subject compares less than expected according to Kotlin's standard < operator.

Parameters:
  • expected: T
fun <T : T> Builder.isGreaterThanOrEqualTo(expected: T): Builder

Asserts that the subject compares greater than or equal to expected according to Kotlin's standard >= operator.

Parameters:
  • expected: T
fun <T : T> Builder.isLessThanOrEqualTo(expected: T): Builder

Asserts that the subject compares less than or equal to expected according to Kotlin's standard <= operator.

Parameters:
  • expected: T
fun <T : T> Builder.isIn(expected: ClosedRange): Builder

Asserts that the subject is in the expected range.

Parameters:
  • expected: ClosedRange
fun <T : E, E, R> Builder.map(function: (E)->R): Builder

Applies Iterable.map with function to the subject and returns an assertion builder wrapping the result.

Parameters:
  • function: (E)->R
fun <T : E, E> Builder.first(): Builder

Maps this assertion to an assertion over the first element in the subject iterable.

Parameters:
  • No parameters
fun <T : E, E> Builder.first(predicate: (E)->Boolean): Builder

Maps this assertion to an assertion over the first element in the subject iterable that matches predicate.

Parameters:
  • predicate: (E)->Boolean
fun <T : E, E> Builder.single(): Builder

Maps this assertion to an assertion over the single element in the subject iterable.

Parameters:
  • No parameters
fun <T : E, E> Builder.last(): Builder

Maps this assertion to an assertion over the last element in the subject iterable.

Parameters:
  • No parameters
fun <T : E, E, R> Builder.flatMap(transform: (E)->Iterable): Builder

Maps this assertion to an assertion over a flattened list of the results of transform for each element in the subject iterable.

Parameters:
  • transform: (E)->Iterable
fun <T : E, E> Builder.all(predicate: Builder.()->Unit): Builder

Asserts that all elements of the subject pass the assertions in predicate.

Parameters:
fun <T : E, E> Builder.any(predicate: Builder.()->Unit): Builder

Asserts that at least one element of the subject pass the assertions in predicate.

Parameters:
fun <T : E, E> Builder.none(predicate: Builder.()->Unit): Builder

Asserts that no elements of the subject pass the assertions in predicate.

Parameters:
fun <T : E, E> Builder.doesNotContain(elements: E): Builder

Asserts that none of elements are present in the subject.

If elements is empty the assertion always fails. If the subject is empty the assertion always passe.

Parameters:
  • elements: E
fun <T : E, E> Builder.doesNotContain(elements: Collection): Builder

Asserts that none of elements are present in the subject.

If elements is empty the assertion always fails. If the subject is empty the assertion always passe.

Parameters:
  • elements: Collection
fun <T : E, E> Builder.containsExactly(elements: E): Builder

Asserts that all elements and no others are present in the subject in the specified order.

If the subject has no guaranteed iteration order (for example a Set) this assertion is probably not appropriate and you should use containsExactlyInAnyOrder instead.

Parameters:
  • elements: E
fun <T : E, E> Builder.containsExactly(elements: Collection): Builder

Asserts that all elements and no others are present in the subject in the specified order.

If the subject has no guaranteed iteration order (for example a Set) this assertion is probably not appropriate and you should use containsExactlyInAnyOrder instead.

Parameters:
  • elements: Collection
fun <T : E, E> Builder.containsExactlyInAnyOrder(elements: E): Builder

Asserts that all elements and no others are present in the subject. Order is not evaluated, so an assertion on a List will pass so long as it contains all the same elements with the same cardinality as elements regardless of what order they appear in.

Parameters:
  • elements: E
fun <T : E, E> Builder.containsExactlyInAnyOrder(elements: Collection): Builder

Asserts that all elements and no others are present in the subject. Order is not evaluated, so an assertion on a List will pass so long as it contains all the same elements with the same cardinality as elements regardless of what order they appear in.

Parameters:
  • elements: Collection
operator fun <T : E, E> Builder.get(i: Int): Builder

Maps this assertion to an assertion on the element at index i in the subject list.

Parameters:
  • i: Int
operator fun <T : E, E> Builder.get(range: IntRange): Builder

Maps this assertion to an assertion on the elements at the sub-list represented by range in the subject list.

Parameters:
  • range: IntRange
operator fun <T : Map, K, V> Builder.get(key: K): Builder

Maps this assertion to an assertion on the value indexed by key in the subject list.

Parameters:
  • key: K
fun <T : Map, K, V> Builder.containsKey(key: K): Builder

Asserts that the subject map contains an entry indexed by key. Depending on the map implementation the value associated with key may be null. This assertion just tests for the existence of the key.

Parameters:
  • key: K
fun <T : Map, K, V> Builder.containsKeys(keys: K): Builder

Asserts that the subject map contains entries for all keys.

Parameters:
  • keys: K
fun <T : Map, K, V> Builder.hasEntry(key: K, value: V): Builder

Asserts that the subject map contains an entry indexed by key with a value equal to value.

Parameters:
  • key: K
  • value: V
fun <T : TemporalAccessor> Builder.isBefore(expected: TemporalAccessor): Builder

Asserts that the subject is before expected.

Parameters:
  • expected: TemporalAccessor
fun <T : TemporalAccessor> Builder.isAfter(expected: TemporalAccessor): Builder

Asserts that the subject is after expected.

Parameters:
  • expected: TemporalAccessor
fun <T : TemporalAccessor> Builder.get(field: TemporalField): Builder

Maps an assertion on the subject to an assertion on the value of the specified temporal field.

Parameters:
  • field: TemporalField
fun <T : TemporalAccessor> Builder.getLong(field: TemporalField): Builder

Maps an assertion on the subject to an assertion on the value of the specified temporal field.

Parameters:
  • field: TemporalField
inline fun <T> Builder.unpacksTo(): Builder

Asserts that the subject is a message of type T.

Parameters:
  • No parameters
inline fun <T> Builder.unpack(): Builder

Maps an assertion on com.google.protobuf.Any to an assertion on an unpacked message of type T.

Parameters:
  • No parameters