I need to test if a returned list of objects is the same as the expected value. Since I do not want to override the equals method just for the test im looking for a solution to compare the classes by values. I found the ReflectionEquals class, but this is not working on a list. Is there any other approach to test this?
@Test
public void testUseOnFieldWithRuleApplied() {
List<Field> argumentFields = new ArrayList<>(Arrays.asList(new Field(1), new Field(2)));
List<Field> expectedFields = new ArrayList<>(Arrays.asList(new Field(0), new Field(1)));
List<Field> returnedFields = this.toBeTestedRule.useOnFields(argumentFields);
assertTrue(new ReflectionEquals(expectedFields).matches(returnedFields));
}
Aucun commentaire:
Enregistrer un commentaire