Mocks From Scratch: Test Doubles in Golang (Part 3 of 4)

Опубликовано: 23 Май 2026
на канале: The Engineering Coach
1,064
23

Welcome to Part 3 of our essential Golang Test Doubles series! I'm your Engineering Coach, and in this episode, we're implementing the gold standard of test doubles: the Mock.

A Mock is a highly expressive Test Double that allows you to pre-program its expectations and verify calls down to the smallest detail. We use Mocks to check that our production code not only gets the right result but also interacts with its dependencies in the exact way we intend.

Continuing our philosophy, you'll see how to implement your own Mock in Golang from scratch, giving you unparalleled confidence in how they function. Mastering Mocks is key to writing clean, maintainable code using TDD.

The code for this 4-part series can be found on GitHub: https://github.com/testingallthething...

Previous in the Series:
Catch up on the foundational types of test doubles:
👉 Watch the video on Stubs here:    • Stubs From Scratch: Test Doubles in Golang...  
👉 Watch the video on Spies here:    • Spies From Scratch: Test Doubles in Golang...  

Next in the Series:
Ready to complete the set? Our final video covers Fakes, the last essential Test Double.
👉 Watch the next video on Fakes here:    • Fakes From Scratch: Test Doubles in Golang...  

Let's Connect
For more software engineering tutorials and coaching, subscribe to The Engineering Coach on YouTube. You can also connect with me on Bluesky or Mastodon.

Mastodon: https://mastodon.social/@braddle
Bluesky: https://bsky.app/profile/braddle1.bsk...
LinkedIn:   / mark-bradley-engineering-coach  

#Golang #GoLang #TestDoubles #Mock #TDD #TestDrivenDevelopment #TheEngineeringCoach