January 2020
Intermediate to advanced
640 pages
16h 56m
English
You can think of mocks as stubs on steroids! Contrary to the fixed behavior exhibited by stubs, mocks allow us to specify, in a declarative way, not only the list of calls that the mock is expected to receive but also their order and expected argument values. In addition, mocks allow us to specify different return values for each method invocation, depending on the argument tuple provided by the method caller.
All things considered, mocks are a very powerful primitive at our disposal for writing advanced tests. However, building mocks from scratch for every single object we want to substitute as part of our tests is quite a tedious task. This is why it's often better to use an external tool and code generation to automate the creation ...