What’s the idiomatic way to make list assertions u...
# kotest
w
What’s the idiomatic way to make list assertions using matchers? That is, having
List<T>
and a
Matcher<T>
, what’s the best way to check something like
List<T>.shouldContainInOrder(List<Matcher<T>>)
?
s
Are you asking how to make your own ?
w
Or whether there is some existing utility/way to efficiently match elements in a list 🙂
Ideally I wanted to have something that’d let me reuse all the existing list matchers, like
shouldHaveSingleElement
,
shouldContainInOrder
etc., only not with specific instances but with matchers
s
Maybe inspectors can help
w
I don’t see a reference to
Inspector*
, is it part of Arrow extensions?
s
list.forAll { // put shoulds here }
list.forOne { // }
It doesn't do ordering through
I think what we need is shouldContainInOrder that accepts a lambda
w
Ah, yes, this is the API I was missing! I already worked around this by creating custom equals/hashCode but the next time I have this issue I’ll look closer at inspectors, thanks 🙂