Mocking Repository with Golang GoMock

ervinismu
pengenpaham
Published in
3 min readApr 24, 2023

--

Photo by Alexander Andrews on Unsplash

Generating mocks is common use case when we write unit testing. In this article, we will learn how to create mocks and use it for testing, we will use GoMock for creating mocks.

Use Case

We have CategoryService and CategoryRepository. When we call method in CategoryService, it will call CategoryRepository for fetching data.

--

--

ervinismu
pengenpaham

full time writer, part time software engineer, long life learner