Skip to content

Tag: junit4

Assert that actual value is in a collection of possible expected values

Is there a way to assert that an actual value equals any of a number of values? Example: I can see that I can just swap the arguments around: but that reverses the semantics. I’m not checking if permittedTransformations is correct; I’m checking actual. Answer You can map the set elements to individual Matcher<String> objects, and combine them with either: