3 ms·
equals/hashCode is useful in tests also when you want the check that the returned object is what you expect, instead of doing field by field comparison: Fo
by krzyk 9y ago
equals/hashCode is useful in tests also when you want the check that the returned object is what you expect, instead of doing field by field comparison:
Foo foo = bar.foo();
Assertions.assertThat(foo).equalTo(new Foo(1, 2, 3));
instead of:
Foo foo = bar.foo();
Assertions.assertThat(foo.getFirst()).equalTo(1);
Assertions.assertThat(foo.getSecond()).equalTo(2);
Assertions.assertThat(foo.getThird()).equalTo(3);