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