Testing in Go: 101
summary
Covers how to write real Go tests using the built-in go test tool and testing package, including concrete examples: table-driven tests for dozens of cases, example functions that appear on godoc, and running tests from the CLI. Shows using testify/assert for Equal, ElementsMatch and Contains and testify/mock to return values conditionally (once, nth call) and fail on unexpected calls. Recommends placing tests in package_test and offers a BDD path with ginkgo+gomega.
AI-written summary · about
chapters (21)
- 0:00Conference intro
- 1:13Why test apps
- 3:00Automated testing benefits
- 5:48Convincing stakeholders
- 9:42Testing pyramid and trophy
- 12:09Go testing tools
- 14:01First unit test
- 16:31Running and interpreting test results
- 20:04Table driven tests
- 22:53Table tests in Go
- 31:30Tests as docs
- 33:56Example tests in Go
- 36:26Test assertions
- 38:36Testify assertions
- 45:17Test doubles explained
- 56:02Stubs in Go
- 1:07:32Mocking with testify
- 1:15:13Test file locations
- 1:24:07Behavior driven development in Go
- 1:26:38BDD with Ginkgo
- 1:30:31Further learning
related talks
44mGo Testing By Example
35mTest like a ninja with Go
42mBuilt-In Testing in Go is More Than Just Passable
24mGo Write Tests using Pragmatic Best Practices
32mTesting in Go: from basic to advanced
28mIntro to Test-Driven Development in Go
34mHow NOT to Write a Test in Go
34mAdvanced Testing Techniques in Go
