TDD

How to AssertThat Two Objects Are Equal

What does it mean that two objects are equal?

4 minute read

The answer to this question is easy: assertThat(a, is(b)) Done. Wait, before closing this web page, let me ask you a few questions. First, let’s make a concrete class Student. public class Student { public final String name; public final int age; public final String id; public Student(String name, int age, String id) { this.name = name; this.age = age; this.id = id; } } Very simple data class. Now let’s try the solution in the beginning of the article.