I am using JUnit 4.12. The assert methods are not generic in nature. For instance, assertEquals method looks like:
static public void assertEquals(Object ex
You want to look assertThat and the Hamcrest matchers; as assertThat actually works with generics:
assertThat(String reason, T actual, Matcher super T> matcher)
So:
assertEquals("abc", 123);
compiles, but fails; whereas
assertThat(123, is("abc"));
won't even compile!
And I am not even mentioning that asserThat calls are much better to read; and give much better information when they fail. You can even use them to compare maps, sets, whatever.
Long story short: there is only one assert that anybody needs - assertThat that is!