Testing code that talks to the network

Back to list2026-07-03
You

Mock the HTTP client or spin up a fake server?

ChatGPT

A fake server, when the protocol matters. Mocks encode your belief about the API, so they keep passing after the real one changes. A local server exercises serialisation, headers and timeouts, which is where the bugs actually live.

You

Which edge cases deserve a test in a small project?

ChatGPT

The ones that already bit you, and the boundaries: empty, one, many, malformed, and the largest input you claim to support. That list catches most regressions without turning the suite into a second implementation.

You

What is the most common way people get this wrong?

ChatGPT

Doing it once and never verifying. The setup is the visible part, so it gets attention, and the check that would catch a silent failure never gets written.