[英]containsOnlyElementsOf returning false on passing two objects
我正在编写使用jUnit作为测试运行程序的黄瓜测试用例。 如果两个对象具有相同的元素,我将使用方法断言true。
assertThat(obj1).containsOnlyElementsOf(obj2)
但是,即使两个对象具有完全相同的元素和相同的值,也不会返回true。 这是堆栈跟踪。
java.lang.AssertionError:
Expecting:
<[com.solambda.kronos.timesheet.dto.TimesheetListRowDto@e12becd7,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@4543a8b3,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@c08e2719,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@d298d9da]>
to contain only:
<[com.solambda.kronos.timesheet.dto.TimesheetListRowDto@6276a018,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@ed39d0fe,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@7bda09e9,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@673947a0]>
elements not found:
<[com.solambda.kronos.timesheet.dto.TimesheetListRowDto@6276a018,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@ed39d0fe,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@7bda09e9,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@673947a0]>
and elements not expected:
<[com.solambda.kronos.timesheet.dto.TimesheetListRowDto@e12becd7,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@4543a8b3,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@c08e2719,
com.solambda.kronos.timesheet.dto.TimesheetListRowDto@d298d9da]>
at com.solambda.kronos.timesheet.steps.TimesheetSteps.i_get_the_following_timesheet s(TimesheetSteps.java:806)
at ✽.Then I get the following timesheets: (com/solambda/kronos/timesheet/Worker_list.feature:43)
有没有人遇到过类似的问题。 让我知道我是否在某处缺少某些东西或做事不正确。
我假设您将assertj-core
用作方法containsOnlyElementsOf
assertj-core
库。
这个方法containsOnlyElementsOf
检查可迭代对象是否具有相同的对象,不仅检查它们是否相等!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.