Reputation: 170
Am I missing something here?
@Test
public void testAnything(){
Random random = new Random();
assertThat(random.nextInt(), is(equalTo(anything())));
}
This doesn't compile. Eclipse complains with "The method assertThat(T, Matcher) in the type MatcherAssert is not applicable for the arguments (int, Matcher>)"
Was there something I missed for the use of anything()? I have used other Hamcrest methods in the past... so what is different about this?
Upvotes: 1
Views: 124
Reputation: 9345
That's not how equalTo
works. It calls Object#equals(Object)
internally and would have to pass anything()
. That doesn't make sense. Just omit it and it works:
Random random = new Random();
assertThat(random.nextInt(), is(anything()));
Upvotes: 2