You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-8
Original file line number
Diff line number
Diff line change
@@ -249,14 +249,19 @@ Check the [tests](https://github.com/mockito/mockito-scala/blob/master/core/src/
249
249
250
250
## Default Answers
251
251
We defined a new type `org.mockito.DefaultAnswer` which is used to configure the default behaviour of a mock when a non-stubbed invocation
252
-
is made on it, the default behaviour is different to the Java version, instead of returning null for any non-primitive or non-final class,
253
-
mockito-scala will return a "Smart Null", which is basically a mock of the type returned by the called method.
254
-
The main advantage of this is that if the code tries to call any method on this mock, instead of failing with a NPE we will
255
-
throw a different exception with a hint of the non-stubbed method call (including its params) that returned this Smart Null,
256
-
this will make it much easier to find and fix a non-stubbed call
257
-
258
-
Most of the Answers defined in `org.mockito.Answers` have it's counterpart as a `org.mockito.DefaultAnswer`, and on top of that
259
-
we also provide `org.mockito.ReturnsEmptyValues` which will try its best to return an empty object for well known types,
252
+
is made on it.
253
+
254
+
The object `org.mockito.DefaultAnswers` contains each one of the provided ones
255
+
256
+
All the mocks created will use `ReturnsSmartNulls` by default, this is different to the Java version, which returns null for any non-primitive or non-final class.
257
+
258
+
A "Smart Null", is nothing else than a mock of the type returned by the called method.
259
+
The main advantage of doing that is that if the code tries to call any method on this mock, instead of failing with a NPE the mock will
260
+
throw a different exception with a hint of the non-stubbed method that was called (including its params),
261
+
this should make much easier the task of finding and fixing non-stubbed calls
262
+
263
+
Most of the Answers defined in `org.mockito.Answers` have it's counterpart in `org.mockito.DefaultAnswers`, and on top of that
264
+
we also provide `ReturnsEmptyValues` which will try its best to return an empty object for well known types,
260
265
i.e. `Nil` for `List`, `None` for `Option` etc.
261
266
This DefaultAnswer is not part of the default behaviour as we think a SmartNull is better, to explain why, let's imagine we
0 commit comments