June 2017
Beginner to intermediate
274 pages
6h 49m
English
We can assign non-mock objects to a mock object's attributes, so that when we access the attribute, we'd get a specific value instead of a generic mock object. This is illustrated by the following simple code example:

We can also assign a customized mock object in place of a method so that we can make the mocked method act more like the original, but in a way, this is controlled by the test. We do this by passing a return value parameter to the mock constructor, which tells the mock object that every time it's called, it should return this value, as shown in the following code example:
If we want the mock to return ...
Read now
Unlock full access