jeudi 31 octobre 2019

Compare two objects by properties in JUnit Tests

I have a method I call which removes, changes and adds other items to a list of a passed list of objects and returns some of these object if they have special characteristics. Now I want to write the test for that class and it drives me crazy since i can not just compare the returned objects with a list of expected objects I hardcoded into the test. I also do not want to override the equals and hashCode method just so the tests will work. Is there any clean approach of doing that in a test? Im quite new to Java, so I have only basic understanding of JUnit and stuff like Mockito :/

Aucun commentaire:

Enregistrer un commentaire