调用final方法,mock final类时,这个类要在@PrepareForTest加上
否则会报错
Also, this error might show up because you use argument matchers with methods that cannot be mocked.
Following methods cannot be stubbed/verified: final/private/equals()/hashCode().
本文探讨了在尝试调用final方法或mock final类时可能遇到的问题及解决办法。特别指出,若要避免错误,必须在@PrepareForTest中声明该类。此外,还讨论了不可mock的方法类型,如final、private、equals()和hashCode()等。
调用final方法,mock final类时,这个类要在@PrepareForTest加上
否则会报错
Also, this error might show up because you use argument matchers with methods that cannot be mocked.
Following methods cannot be stubbed/verified: final/private/equals()/hashCode().
956

被折叠的 条评论
为什么被折叠?