entries
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
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.
A variable amount of additional identification lambdas or null
s.
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)
}
)
}
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
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.
A variable amount of additional identification lambdas or null
s.
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)
}
)
}
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
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.
A variable amount of additional identification lambdas or null
s.
The lambda configuring the InOrderOnlyReportingOptions.