Skip to content

Instantly share code, notes, and snippets.

@hakanai
Created August 3, 2010 03:30
Show Gist options
  • Select an option

  • Save hakanai/505783 to your computer and use it in GitHub Desktop.

Select an option

Save hakanai/505783 to your computer and use it in GitHub Desktop.
import org.hamcrest.Matchers;
public class WtfHamcrest {
@Test
public void testWtfHamcrest()
{
Integer a = 1;
String b = "2";
assertThat(a, Matchers.<Object>is(not(equalTo(b))));
assertThat(b, Matchers.<Object>is(not(equalTo(a))));
/*
java.lang.AssertionError:
Expected: is <not "2">
got: <1>
*/
}
}
@hakanai
Copy link
Author

hakanai commented Aug 3, 2010

Turns out that removing the is() fixes this.

@hakanai
Copy link
Author

hakanai commented Aug 3, 2010

Declaring both variables as Object also fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment