Comparison
Network mockingvsStub
Network mocking
you intercepted the request at the network layer instead of stubbing the function that makes it.
Replacing responses at the HTTP boundary so the code under test makes its real requests and receives controlled answers. It keeps the fetching code in the test's path, unlike stubbing the client, which is where header, serialisation and error-handling bugs hide. The risk is the usual one for any fake: handlers that drift from what the real API returns give you a green suite and a broken feature.
Full entry →Stub
you hard-code the collaborator to return a fixed value so the code under test has something to work with.
A double that returns canned responses, providing inputs to the code under test. It has no assertions and no logic; it exists so the test can reach the code path you care about. If your test asserts on what the stub was called with, you have written a mock.
Full entry →