1
JUnit测试...JUnit比较除集合对象中的指定字段之外的集合中的对象
它需要比较2个单个元素,但某些字段除外。我可以使用assertj这个:
Assertions.assertThat(actual).isEqualToIgnoringGivenFields(except, "id", "innerCollection");
它的效果很好。但这还不够。我还需要比较内部收藏。我知道只有id在内部集合中是不同的。是否有可能比较像
Assertions.assertThat(to.getInnerCollection()).isEqualToIgnoringGivenFields(from.getInnerCollection()
, {except fields in collection elements});
我很高兴你发现我的答案有帮助:-) – GhostCat