-
Couldn't load subscription status.
- Fork 0
What is spying
Devrath edited this page Jun 26, 2021
·
1 revision
A spy is a partial mock in mocking frameworks meaning a part of the object will be mocked and part will be used in real method invocations.
-
Mockis actually trying to be an interface.- When you specify a
mockyou are just checking the return method of that mock. -
Mocksees just the method calls and not the structure inside it. - Thus
mockruns the method and ignores the body.
- When you specify a
-
Spyis trying to be the actual class.- By using a spy, the entire class is running, the body of the class is running, the entire structure is running.
-
Spysees not just the calls of method but also the body in it. - Thus
spyruns the method and the body.