User { @Override public String toString() { return name + " (" + nickname + ')'; } User(final String nickname, final String realname); @Override String toString(); final String nickname; final String name; }
@Test public void toStringShouldIncludeNickname() { User u = new User(nick, name); assertThat(u.toString(), containsString(nick)); }
@Test public void toStringShouldIncludeRealName() { User u = new User(nick, name); assertThat(u.toString(), containsString(name)); }