Nov 8, 2018

assertThat() in Junit

assertThat() is better than assertEquals() and assertTrue() etc.  assertThat() has better messages and is easier to read for more complicate test cases.

Example:

assertThat(result, is(88));
assertThat(x, is(not(88)));
assertThat(result, containsString("i88.ca"));
assertThat(myList, hasItems("i88.ca", "wp.i88.ca"));
assertThat(y, either(containsString("province")).or(containsString("state")));