Loading…
0+ curated questions with the same answer shape every time: quick recap, deep dive, pitfalls, and follow-ups. Coverage includes .
Mocking and integration testing in Go builds on the language's interface system — if you designed your dependencies as interfaces, mocking them is straightforward. This module covers gomock and mockgen (the code-generation-based mock library that generates type-safe mocks from your interfaces — EXPECT(), Return(), gomock.InOrder for sequential call assertions), manual interface mocking (writing a simple test-double struct that implements the interface — preferred for simpler cases), the httptest package (httptest.NewServer for spinning up a real HTTP server in tests, httptest.NewRecorder for testing handlers without a server), testcontainers-go (spinning up a real PostgreSQL container in a Go test, how to get the dynamic port, the module vs raw approach), golden file testing for testing JSON/protobuf response shapes, and the test pyramid applied to a Go microservice — how many unit tests, integration tests, and end-to-end tests are the right ratio and why.
Full catalog
Topics are ordered for learning. Within each topic, rows are numbered 1–0 globally so you always know where you are. Collapse topics if you want a lighter view — use Expand all when you need the full list again.
Numbers 1–0 follow the order we recommend — click any row to open the full answer, or use the sticky Next link at the bottom of each page to go Q1 → Q0.