doc / ch.tutteli.atrium.api.infix.en_GB / and

and

inline infix fun <T> Expect<T>.and(o: o): Expect<T> (source)

Can be used to separate single assertions.

For instance expect(1).isLessThan(2).and.isGreaterThan(0) creates two assertions (not one assertion with two sub-assertions) - the first asserts that 1 is less than 2 and the second asserts that 1 is greater than 0. If the first assertion fails, then the second assertion is not evaluated.

// `and` is just a filler word does not have any behaviour
expect(13) toBeGreaterThan 5 and o toBeLessThan 20

// i.e. the above is equivalent to:
expect(13) toBeGreaterThan 5 toBeLessThan 20

Parameters

o - The filler object o.

Return
an Expect for the subject of this expectation.

Since
0.12.0

infix fun <T> Expect<T>.and(assertionCreator: Expect<T>.() -> Unit): Expect<T> (source)

Can be used to create a group of sub assertions when using the fluent API.

For instance expect(1).isLessThan(3).and { isEven(); isGreaterThan(1) } creates two assertions where the second one consists of two sub-assertions. In case the first assertion holds, then the second one is evaluated as a whole. Meaning, even though 1 is not even, it still evaluates that 1 is greater than 1. Hence the reporting might (depending on the configured Reporter) contain both failing sub-assertions.

expect(13).toBeAnInstanceOf<Int>() and {
    it toBeGreaterThan 5
    it toBeLessThan 20
}

fails {
    expect(13).toBeAnInstanceOf<Int>() and {
        // introduces an expectation group block
        // all expectations are evaluated inside an expectations group block; for more details:
        // https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups
        it notToEqualOneOf values(1, 2, 13) // fails
        it toBeLessThan 10                  // still evaluated and included in the error report
        //                                     use `.and.` if you want fail fast behaviour
    }
}

Return
an Expect for the subject of this expectation.

infix fun <E, T> IterableLikeContains.EntryPointStep<E, T, InOrderSearchBehaviour>.and(only: only): IterableLikeContains.EntryPointStep<E, T, InOrderOnlySearchBehaviour> (source)

Defines that the constraint "only the specified entries exist in the IterableLike" shall be applied to this sophisticated contains in order IterableLike assertion.

Return
The newly created builder.

Since
0.14.0 -- API existed for Iterable but not for IterableLike.

infix fun <K, V, T> MapLikeContains.EntryPointStep<K, V, T, InOrderSearchBehaviour>.and(only: only): MapLikeContains.EntryPointStep<K, V, T, InOrderOnlySearchBehaviour> (source)

Defines that the constraint "only the specified entries exist in the MapLike" shall be applied to this sophisticated contains in order MapLike assertion.

Return
The newly created builder.

Since
0.15.0