在我尝试的所有JUnit版本中(直到4.8.1),一个失败的assertThat将显示一个错误消息,看起来像:
期望值:[describeTo]
实际值:[对象的字符串表示形式]
换句话说,它将显示对象的toString()而不是Matcher的不匹配描述。如果我使用来自org.hamcrest.MatcherAssert.assertThat的assertThat,则它将调用“describeMismatch”并显示更有帮助的错误消息。
我是否使用Junit不正确,还是当前没有版本的JUnit可以做到我想要的?大多数人都使用Hamcrest的assertThat吗?