Mock the Wire
Blog post from Speedscale
Earlier tests for a package notifier replaced the carrier lookup function entirely, effectively testing decision logic while leaving URL construction, headers, status handling, and JSON parsing untested. The post advocates adding small wire-level tests using a locally controlled fake HTTP server, allowing the real client to send requests and parse responses while tests verify paths, API-key and Accept headers, successful decoding of all known shipment states, 503 error handling, and malformed JSON behavior. It compares available server tools in Go, Java, Node.js, and Python, noting that Java and Node require test dependencies while Go and Python can use standard libraries, and highlights HTTP header case normalization in Python. Function stubs and fake servers serve complementary purposes: stubs efficiently test notifier behavior at an application seam, while fake-server tests validate the client’s protocol implementation between that seam and the network socket. However, because the fake server returns responses written by the test authors, these tests cannot confirm that the real carrier API continues to use the expected contract, such as field names or response structures.
No tracked trend matches for this post yet.
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.