January 2020
Intermediate to advanced
640 pages
16h 56m
English
Now that we are aware of the implementation details of our example project, we can go ahead and write a simple, mock-based unit test for it. Before we begin, we need to create a mock for the API interface. This can be achieved by invoking the mockgen tool with the following options:
$ mockgen \
-destination mock/dependency.go \
github.com/PacktPublishing/Hands-On-Software-Engineering-with-Golang/Chapter04/dependency \
API
The preceding command does the following: