7. Testing
Testing in Go, as in any language, is a subject worthy of its own book. Unfortunately, covering all topics, such as benchmarking, example tests, and design patterns, is outside the scope of this book. In this chapter, we cover the fundamentals of testing in Go, including writing, running, and debugging tests. We also cover table driven tests, test helpers, and code coverage.
Testing Basics
Go ships with a powerful testing framework, and as such, there is a strong emphasis on testing in Go. Tests in Go are written in the Go language, so there is no need to learn another syntax. Because the language was designed with testing in mind, it tends to be easier to create and understand tests in Go than in some other languages.
As with any ...
Get Go Fundamentals: Gopher Guides now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.