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?
That’s not how
equalToworks. It callsObject#equals(Object)internally and would have to passanything(). That doesn’t make sense. Just omit it and it works: