- Introduction to Go’s standard testing library
- Introduction to Test-Driven Development (TDD)
- Test naming, output, and failure diagnostics
- Table-Driven Tests
- Writing DRY and readable test suites
- Using
t.Runto structure subtests - Hands-on: Table-driven tests for various scenarios
- Organizing tests in packages
- Code coverage: generating and interpreting with
go test -cover - Using
go tool coverfor visual coverage - Hands-on: Refactor tests and check coverage
- Interfaces for testability
- Manual mocking vs. mocking frameworks
- Mocking time (
clockwork) - Hands-on: Writing and using mocks in service layer tests
- Writing performance benchmarks with
BenchmarkXxx - Testing concurrent code (data races,
-raceflag,testing/synctest) - Creating mock containers for integration tests.
- Hands-on: Writing a benchmark and a concurrent test
- Using
stretchr/testifyfor more expressive assertions - Setup / teardown strategies ()
- Golden files and snapshot testing
- Hands-on: Convert basic tests to use
testify
By the end of the training, participants will:
- Understand how to write and structure tests in Go
- Be able to test real-world codebases with unit, integration, and concurrent tests
- Know how to use tools like
testify,go test, and code coverage utilities effectively - Be familiar with Go testing patterns and performance testing (edited)