
Explore unit testing for Golang developers with real-world examples, starting from the basics and guiding newcomers who come from other languages.
Understand how software testing runs your code with inputs to verify outcomes. Explore test scenarios like a Google search to illustrate naming, instantiation, action, and assertions in tests.
Cover unit testing in Go by building a discount calculator that applies a discount when the purchase exceeds a minimum amount, and writing tests with the Go testing package.
Discover how unit tests use the arrange, act, and assert pattern to organize scenarios, improve readability, and guide focused, single-scenario testing.
Explore the Go test command, its two execution modes, and how test caching reuses previous results to speed up running tests across packages.
Learn to craft clear test failure messages in Go using the testing package, log and logf, and error or errorf to explain why tests fail.
Discover how table driven tests centralize test cases for a Go discount calculator, avoid repeated code, and simplify adding edge cases.
Learn to use sub tests in Go to treat each loop iteration as a distinct test case with t.Run, enabling precise failures and easy debugging.
Learn to prevent inconsistent Go tests by using FailNow and Fatalf to stop execution on zero minimum purchase amount errors in a discount calculator, clarifying failures and messages.
Mock dependencies in unit tests by introducing a repository interface and a mock discount repository, so the discount calculator finds current discount without a real database.
Clarify the difference between unit and integration tests in Go, including functional and end-to-end naming, explain why unit tests are fast and isolated while integration tests are broader and slower.
Explore using Testify for idiomatic assertions in Go tests, replacing manual checks with assert calls, and leveraging descriptive messages and diverse assertion methods for complex comparisons.
Learn to mock the discount repository with testify's mock.Mock in go tests, using a discount value field or a counter to return 20 or 0 for clear, reliable, readable tests.
Learn how stubs serve as test doubles in Go unit tests, using testify to simulate repositories for user registration and a bad-word filter.
Explore mocks in unit testing for Go developers, learning to assert method calls and verify a user is not registered when bad words are found, while contrasting with stubs.
Explore Go unit testing with mock and dummy objects in a credit card authorization scenario, enforcing a five-attempt limit and verifying gateway interactions across success, failure, and limit-reached cases.
Complete the unit testing for Go developers course and stay updated. Reach out if you’re missing content so we can talk about it, and I hope you learned a lot.
In this course, you will learn how Go developers are testing their Go code in the companies. We will use only real world problems and we will show all the examples using code.
You will learn the concepts of unit testing, the Go testing package and Testify, the most used library for tests in Go.
If you came from another languages. I'm sure you are trying to figure out how to apply the same concepts using Golang, in this course we will answer all your questions.
And if Go is your first language or you don't know much about unit testing, don't worry, we will cover everything, from the basic to advanced.