Mockito如何SmartNullPointerException帮助我?

enxuqcxy  于 2022-11-08  发布在  其他
关注(0)|答案(1)|浏览(130)

刚知道了Mockito中的可能性,对我们来说是SmartNullPointerException(基本上设置了RETURNS_SMART_NULLS
但我不太明白它对我有什么帮助。它只是普通NPE的一个 Package 。我错过了什么?

y4ekin9u

y4ekin9u1#

从RETURNS_SMART_NULLS的文件中:
This implementation can be helpful when working with legacy code. Unstubbed methods often return null. If your code uses the object returned by an unstubbed call you get a NullPointerException. This implementation of Answer returns SmartNull instead of null. SmartNull gives nicer exception message than NPE because it points out the line where unstubbed method was called. You just click on the stack trace.

相关问题