In Junit5 i used the following snippet often to test if a collection contains elements that fullfill certain criteria:
assertThat("The list of addresses", addresses.getAddressReferences(), containsInAnyOrder(
allOf(
hasProperty("id", is("abc")),
hasProperty("role", is(SENDER))
),
allOf(
hasProperty("id", is("def")),
hasProperty("role", is(RECEIVER))
)
));
I did not yet find a way to express this in kotest
I tried shouldContainExactlyInAnyOrder
and such but they expect an actual object. I don't know how to express that i want to test each element against a different matcher.
I also checked the inspectors which might be the solution but they only seem to help to make assertions on ALL elements in the list at once.