Answer the question
In order to leave comments, you need to log in
Is there a way to compare objects using their getters?
The test needs to compare two objects by accessing their getters. But I do not want to write such checks:
Assertions.assertThat(this.getName()).isEqualTo(that.getName());
Assertions.assertThat(this.getAddress()).isEqualTo(that.getAddress());
Assertions.assertThat(this.getAge()).isEqualTo(that.getAge());
...
Answer the question
In order to leave comments, you need to log in
you need to override the equals and hashCode methods of the class
idea it can generate (Alt + Insert)
then you will just write this.equals(that)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question