doc / ch.tutteli.atrium.creating / IAssertionPlant

IAssertionPlant

interface IAssertionPlant<out T : Any> : IAssertionPlantWithCommonFields<T> (source)

Represents a plant for IAssertions and offers the possibility to check all the added assertions.

You can think of it as an IAssertion factory which does more than just factoring but also provides quality assurance capabilities.

Properties

and open val and: IAssertionPlant<T>

Can be used to separate assertions when using the fluent-style API.

Inherited Properties

commonFields abstract val commonFields: CommonFields<T>

CommonFields of this plant.

subject open val subject: T

The subject for which this plant will create/check IAssertions.

Functions

addAssertion abstract fun addAssertion(assertion: IAssertion): IAssertionPlant<T>

Adds the given assertion to the plant.

checkAssertions abstract fun checkAssertions(): IAssertionPlant<T>

Checks the so far added IAssertions and reports if one of them fails.

createAndAddAssertion abstract fun createAndAddAssertion(description: String, expected: Any, test: () -> Boolean): IAssertionPlant<T>

Creates an IAssertion based on description, expected and test and adds it to the plant.

Extension Properties

message val <T : Throwable> IAssertionPlant<T>.message: IAssertionPlant<String>

Creates an IAssertionPlantNullable for the message of the plant's subject (which is an Throwable) and makes the assertion that message isNotNull.

Extension Functions

contains fun <T : CharSequence> IAssertionPlant<T>.contains(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject contains the expected.

fun <T : CharSequence> IAssertionPlant<T>.contains(expected: CharSequence, vararg otherExpected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject contains the expected and otherExpecteds (if defined).

fun <T : CharSequence> IAssertionPlant<T>.contains(expected: Any, vararg otherExpected: Any): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject contains expected's toString representation and the toString representation of the otherExpected (if defined).

containsNot fun <T : CharSequence> IAssertionPlant<T>.containsNot(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not contain the expected.

fun <T : CharSequence> IAssertionPlant<T>.containsNot(expected: CharSequence, vararg otherExpected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not contain the expected and neither one of the otherExpecteds (if defined).

fun <T : CharSequence> IAssertionPlant<T>.containsNot(expected: Any, vararg otherExpected: Any): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not contain expected's toString representation and neither one of the otherExpected's toString representation (if defined).

createAssertionsAndCheckThem fun <T : Any> IAssertionPlant<T>.createAssertionsAndCheckThem(createAssertions: IAssertionPlant<T>.() -> Unit): IAssertionPlant<T>

Uses this plant as receiver of the given createAssertions function and then calls IAssertionPlant.checkAssertions.

endsNotWith fun <T : CharSequence> IAssertionPlant<T>.endsNotWith(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not end with expected.

endsWith fun <T : CharSequence> IAssertionPlant<T>.endsWith(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject ends with expected.

genericCheck fun <T : Any> IAssertionPlant<T>.genericCheck(feature: KProperty0<Boolean>): IAssertionPlant<T>

Use this function to make the assertion about the existing property feature of the IAssertionPlant.subject that the property is true.

genericNotCheck fun <T : Any> IAssertionPlant<T>.genericNotCheck(feature: KProperty0<Boolean>): IAssertionPlant<T>

Use this function to make the assertion about the existing property feature of the IAssertionPlant.subject that the property is false.

hasSize fun <T : Collection<*>> IAssertionPlant<T>.hasSize(size: Int): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject's Collection.size is size.

isA fun <TSub : Any> IAssertionPlant<Any>.isA(): IAssertionPlant<TSub>

Makes the assertion that IAssertionPlant.subject is a TSub (the same type or a sub-type).

fun <TSub : Any> IAssertionPlant<Any>.isA(createAssertions: IAssertionPlant<TSub>.() -> Unit): IAssertionPlant<TSub>

Makes the assertion that IAssertionPlant.subject is a TSub (the same type or a sub-type) and if so, uses createAssertions which could create further assertions which are lazily evaluated at the end.

isEmpty fun <T : Collection<*>> IAssertionPlant<T>.isEmpty(): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject is an empty Collection.

isGreaterOrEquals fun IAssertionPlant<Int>.isGreaterOrEquals(expected: Int): IAssertionPlant<Int>

Makes the assertion that IAssertionPlant.subject is greater than or equals expected.

isGreaterThan fun IAssertionPlant<Int>.isGreaterThan(expected: Int): IAssertionPlant<Int>

Makes the assertion that IAssertionPlant.subject is greater than expected.

isNotEmpty fun <T : CharSequence> IAssertionPlant<T>.isNotEmpty(): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject.kotlin.text.isNotEmpty.

isNotSame fun <T : Any> IAssertionPlant<T>.isNotSame(expected: T): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject is not the same instance as expected.

isSame fun <T : Any> IAssertionPlant<T>.isSame(expected: T): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject is the same instance as expected.

isSmallerOrEquals fun IAssertionPlant<Int>.isSmallerOrEquals(expected: Int): IAssertionPlant<Int>

Makes the assertion that IAssertionPlant.subject is smaller than or equals expected.

isSmallerThan fun IAssertionPlant<Int>.isSmallerThan(expected: Int): IAssertionPlant<Int>

Makes the assertion that IAssertionPlant.subject is smaller than expected.

its fun <T : Any, TFeature> IAssertionPlant<T>.its(feature: KProperty0<TFeature>): IAssertionPlantNullable<TFeature>

Creates an IAssertionPlantNullable using the given feature as subject.

fun <T : Any, TFeature : Any> IAssertionPlant<T>.its(feature: KProperty0<TFeature>, createAssertions: IAssertionPlant<TFeature>.() -> Unit): IAssertionPlant<TFeature>

Creates an IAssertionPlant which lazily evaluates IAssertions using the given feature as subject.

message fun <T : Throwable> IAssertionPlant<T>.message(createAssertions: IAssertionPlant<String>.() -> Unit): IAssertionPlant<String>

Creates an IAssertionPlantNullable for the message of the plant's subject (which is an Throwable) and makes the assertion that message isNotNull and uses createAssertions which might create further IAssertions which are lazily evaluated at the end.

notToBe fun <T : Any> IAssertionPlant<T>.notToBe(expected: T): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject is not (does not equal) expected.

startsNotWith fun <T : CharSequence> IAssertionPlant<T>.startsNotWith(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject does not start with expected.

startsWith fun <T : CharSequence> IAssertionPlant<T>.startsWith(expected: CharSequence): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject starts with expected.

toBe fun <T : Any> IAssertionPlant<T>.toBe(expected: T): IAssertionPlant<T>

Makes the assertion that IAssertionPlant.subject is (equals) expected.