entries

fun <T : Any> entries(assertionCreatorOrNull: Expect<T>.() -> Unit?, vararg otherAssertionCreatorsOrNulls: Expect<T>.() -> Unit?): Entries<T>(source)

Helper function to create an Entries based on the given assertionCreatorOrNull and otherAssertionCreatorsOrNulls -- allows expressing { }, vararg { }.

In case null is used for an identification lambda then it is expected that the corresponding entry is null as well.

Parameters

assertionCreatorOrNull

The identification lambda identifying the entry where an entry is considered to be identified if it holds all Assertions the lambda creates. In case it is defined as null, then an entry is identified if it is null as well.

otherAssertionCreatorsOrNulls

A variable amount of additional identification lambdas or nulls.

Samples

expect(listOf(3, 5, null)) toContainExactly entries(
    { it toEqual 3 },
    { it toBeLessThan 11 },
    null
)

fails {
    expect(listOf(3, 5, 7)) toContainExactly entries(
        { it toBeGreaterThan 2 },
        { it toBeLessThan 11 }
    )
}

fails {
    expect(listOf(3, 5)) toContainExactly entries(
        { it toEqual 1 },       // fails
        { it toBeLessThan 11 }, // succeeds
        // optional
        reportOptionsInOrderOnly = { // allows configuring reporting, e.g.
            showOnlyFailing() // would not show the successful `toBeLessThan(11)`
            showOnlyFailingIfMoreExpectedElementsThan(10)
        }
    )
}

fun <T : Any> entries(assertionCreatorOrNull: Expect<T>.() -> Unit?, vararg otherAssertionCreatorsOrNulls: Expect<T>.() -> Unit?, reportOptionsInOrderOnly: InOrderOnlyReportingOptions.() -> Unit): WithInOrderOnlyReportingOptions<Entries<T>>(source)

Helper function to create a WithInOrderOnlyReportingOptions wrapping an Entries based on the given assertionCreatorOrNull and otherAssertionCreatorsOrNulls as well as the given reportOptionsInOrderOnly-configuration-lambda -- allows expressing { }, vararg { }, reportOptionsInOrderOnly = { ... }.

In case null is used for an identification lambda then it is expected that the corresponding entry is null as well.

Since

0.18.0

Parameters

assertionCreatorOrNull

The identification lambda identifying the entry where an entry is considered to be identified if it holds all Assertions the lambda creates. In case it is defined as null, then an entry is identified if it is null as well.

otherAssertionCreatorsOrNulls

A variable amount of additional identification lambdas or nulls.

reportOptionsInOrderOnly

The lambda configuring the InOrderOnlyReportingOptions.

Samples

expect(listOf(3, 5, null)) toContainExactly entries(
    { it toEqual 3 },
    { it toBeLessThan 11 },
    null
)

fails {
    expect(listOf(3, 5, 7)) toContainExactly entries(
        { it toBeGreaterThan 2 },
        { it toBeLessThan 11 }
    )
}

fails {
    expect(listOf(3, 5)) toContainExactly entries(
        { it toEqual 1 },       // fails
        { it toBeLessThan 11 }, // succeeds
        // optional
        reportOptionsInOrderOnly = { // allows configuring reporting, e.g.
            showOnlyFailing() // would not show the successful `toBeLessThan(11)`
            showOnlyFailingIfMoreExpectedElementsThan(10)
        }
    )
}

fun <T : Any> entries(assertionCreatorOrNull: Expect<T>.() -> Unit?, vararg otherAssertionCreatorsOrNulls: Expect<T>.() -> Unit?, reportOptionsInAnyOrderOnly: InAnyOrderOnlyReportingOptions.() -> Unit): WithInAnyOrderOnlyReportingOptions<Entries<T>>(source)

Helper function to create a WithInAnyOrderOnlyReportingOptions wrapping an Entries based on the given assertionCreatorOrNull and otherAssertionCreatorsOrNulls as well as the given reportOptionsInAnyOrderOnly-configuration-lambda -- allows expressing { }, vararg { }, reportOptionsInAnyOrderOnly = { ... }.

In case null is used for an identification lambda then it is expected that the corresponding entry is null as well.

Since

0.18.0

Parameters

assertionCreatorOrNull

The identification lambda identifying the entry where an entry is considered to be identified if it holds all Assertions the lambda creates. In case it is defined as null, then an entry is identified if it is null as well.

otherAssertionCreatorsOrNulls

A variable amount of additional identification lambdas or nulls.

reportOptionsInAnyOrderOnly

The lambda configuring the InOrderOnlyReportingOptions.