Demystify Unit Tests

There was a time I argue within my dev team what a unit test is. Many devs write unit tests with a real DB interaction or with other dependecies but they still call it unit tests. I strongly agree that when we want to test interactions, we should NOT mock the DB with 3rd party dependencies like “github.com/DATA-DOG/go-sqlmock”: When we want to test interactions, we should and always use real DB....

October 3, 2023 · 4 min · 840 words · David Lee

My Tricks on Outpacing an Entire Team in Tests

I don’t want to waste your time and let’s hit the point, this article mainly discusses about how to speed up your test experience with mocks. below are my tricks used in generate.go file: This is the package we need to install: go install github.com/vektra/mockery/v2@latest Mockery provides the ability to easily generate mocks for Golang interfaces. Running go generate will generate mocks for all interfaces within the directories: The above example shows that interfaces in application....

October 3, 2023 · 2 min · 421 words · David Lee