是否有Java实用程序可以对两个对象进行深入比较? [英] Is there a Java utility to do a deep comparison of two objects?

查看:66
本文介绍了是否有Java实用程序可以对两个对象进行深入比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在测试中基于其字段值对未实现equals方法的两个对象进行深度"比较?

How to "deep"-compare two objects that do not implement the equals method based on their field values in a test?

原始问题(由于缺乏精确性并因此不符合SO标准而被关闭),保留下来用于记录目的:

Original Question (closed because lack of precision and thus not fulfilling SO standards), kept for documentation purposes:

我正在尝试为大型项目中的各种 clone()操作编写单元测试,而且我想知道是否存在某个能够容纳两个对象的类.相同的类型,进行深入比较,然后说出它们是否相同?

I'm trying to write unit tests for a variety of clone() operations inside a large project and I'm wondering if there is an existing class somewhere that is capable of taking two objects of the same type, doing a deep comparison, and saying if they're identical or not?

推荐答案

Unitils 具有此功能:

通过反射进行平等断言,具有不同的选项,例如忽略Java默认值/空值和忽略集合的顺序

Equality assertion through reflection, with different options like ignoring Java default/null values and ignoring order of collections

这篇关于是否有Java实用程序可以对两个对象进行深入比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆