GoLang Unit Testing and Mock Testing Tutorial
In this video we are going to learn what a unit test and what mocking and stubs are. We learn how to create go files for testing, using the testing library, and set up basic unit tests plus using a slice to run a multitude of tests.
We also use the httptest package to set up a mock server to mimic getting JSON data from the web. So that we learn how to do mock testing in golang. There are a lot of different ways to do mock testing, in this tutorial we set up a simple mock test using a stub server to return JSON data for testing.
More information on the loop back interface: https://en.wikipedia.org/wiki/Loopback#Virtual_loopback_interface
More information on the net/http/httptest package: https://pkg.go.dev/net/http/httptest
All code found in this video will be at: š» https://github.com/NerdCademyDev/golang
š¤ Let me know if you have any issues!
ā”ļø What else would you like me to cover?
š Always Keep Learning!
55305271 Bytes