How to achieve an effect of AssertJ's satisfiesAnyOf with KoTest?

28 Views Asked by At

With AssertJ you can say:

assertThat(list).satisfiesAnyOf(
    listParam -> assertThat(listParam).contains(Tags.SWEETS, Tags.HIGH),
    listParam -> assertThat(listParam).contains(Tags.SOUPS, Tags.RED)
);

How am I supposed to express the same with KoTest? Is there some meta-assertion which passes as soon as one of the internal assertions is successful?

1

There are 1 best solutions below

0
Emil Kantis On BEST ANSWER

You can use any, like:

any {
  list.shouldContain(Tags.SWEETS, Tags.HIGH)
  list.shouldContain(Tags.SOUPS, Tags.RED)
}

or you could create a composite matcher that tests for either of the tags:

list should contain(Tags.SWEETS, Tags.HIGH).or(contain(Tags.SOUPS, Tags.RED))