Simplifying Testing using a Mock Tool
Let's learn to simplify tests using the Mock tool.
Transforming stub into mock
Let’s consider how to transform our smart stub into a mock. To do so would involve:
- Trapping and storing the parameters passed to the
get()
method. - Supporting the ability to verify upon test completion that the stored parameters to
get()
contains the expect parameters.
Creating a mock that performs those steps may seem like overkill. What does it get us? Actually, not much at all. If we were to write a second or third test ...
Access this course and 1400+ top-rated courses and projects.