Skip to content

Tag: hamcrest

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:

Hamcrest When to use Is or equalTo

I’m new using hamcrest. While I’m discovering how to use it I have been a doubt about when to use is or equalTo. Is there any difference between is and equalTo, although it is conceptually or ocasionally? It seems to behave the same. Why do you would use one instead of the other? Answer The Javadoc for Matchers is pretty