在我尝试过的每个 JUnit 版本(最高 4.8.1)中,失败的 assertThat 将显示如下错误消息:
预期:[describeTo]
得到:[对象的字符串表示]
换句话说,它将显示对象的 toString(),而不是来自 Matcher 的不匹配描述。如果我使用 org.hamcrest.MatcherAssert.assertThat 中的 assertThat,那么它将调用“describeMismatch”并显示更有用的错误消息。
我是在错误地使用 Junit,还是目前没有可以满足我要求的 JUnit 版本?大多数人会使用 Hamcrest assertThat 吗?