truth icon indicating copy to clipboard operation
truth copied to clipboard

Add MapSubject#containsAnyOf

Open nakulj opened this issue 3 years ago • 2 comments

I have a test that can create a map with one of two possible entries. It would be nice if I could use containsAnyOf like I can with an IterableSubject.

nakulj avatar Jun 07 '22 20:06 nakulj

Until such time as that method may be added, you could work around it by using containsAnyOf on the map's entrySet().

amalloy avatar Jun 10 '22 22:06 amalloy

Alan's response is better than my first thought, and you should do that :)

In a slightly different situation, you might find it useful to use Fuzzy Truth (a.k.a. comparingValuesUsing): You could specify the key you expect and (essentially) a predicate that matches any of the values you expect.

But hopefully we'll add the thing you really want eventually. Thanks for the request.

cpovirk avatar Jun 13 '22 14:06 cpovirk