java 单元测试总是给出否定的结果,尽管数组是相同的

问题描述

assertEquals(expected,actual);
assertArrayEquals(result.toArray(),expected.toArray());
assertthat(result,hasItems(
    Transfer("888881","111111",3
}

以上所有给出:

java.lang.AssertionError: expected: java.util.ArrayList<[Transfer(from=888881,to=111111,amount=3)]> but was: java.util.ArrayList<[Transfer(from=888881,amount=3)]>

错误显示的数组不是相同的吗?

pom.xml:

<dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13</version>
        <scope>test</scope>
        <exclusions>
      <exclusion>
          <groupId>org.hamcrest</groupId>
          <artifactId>hamcrest-core</artifactId>
      </exclusion>
  </exclusions>
    </dependency>
<dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <version>1.3</version>
      <scope>test</scope>
  </dependency>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)