Advanced Testing Techniques
summary
Shows concrete patterns: three levels of dependency injection for SQL (inject DSN, sql.DB, or a custom store interface), a practical way to override time.Now via package variable for deterministic tests, and why exported channels make tests hard so prefer blocking methods that are cancelable. Recommends not exporting wide library interfaces, instead defining small consumer/producer interfaces (used to replace Sarama/Kafka in tests). Demonstrates parameterized suites swapping Redis and memcache backends, and HTTP tests using httptest.ResponseRecorder and docker-entrypoint-initdb.d for Postgres-backed workflows.
AI-written summary · about
chapters (25)
- 0:00Introduction
- 1:42Why test
- 2:33Agenda
- 2:50Disclaimer
- 3:13Outline
- 3:33Dependency Injection
- 4:01Dependency Injection Examples
- 6:33Time Override
- 8:01Channels
- 9:39Queue Lib
- 10:03Error Handling
- 10:51Synchronous Testing
- 11:50Interfaces
- 12:59Soma
- 16:32Benefits
- 17:35Parametrize Test Suites
- 18:23Example
- 20:56Why
- 21:34HTTP Server Test
- 22:17HTTP Test Package
- 24:03TableDriven Testing
- 25:03Session Testing
- 25:53Database Driven Testing
- 26:50Table Driven Testing
- 27:30Wrapping Up
related talks
34mAdvanced Testing Techniques in Go
57mAdvanced Testing Techniques: Tips from the trenches
44mTesting the untestable - patterns and use cases analysis
26mTesting the Tricky Stuff
48mModern Testing Patterns
01h 05mMicrotesting
58mTDD for database related code, how is it possible?
40mIntegration Testing from the Trenches - Rebooted
