The Power of Go: Tests

The Power of Go: Tests

$29.95

This book introduces you to all Go’s testing facilities, shows you how to use them to write tests for the trickiest things, and distils the collected wisdom of the Go community on best practices for testing Go programs.

Add To Cart

Who is this book for?

Go developers who want to build reliable, maintainable software with confidence, guided by effective tests.

What problem does it solve?

Many developers treat testing as something you do after the code is written.

The problem is that difficult-to-test code is often difficult-to-understand code. When a test is hard to write, that’s often a sign that the design itself needs improvement.

This book shows you how to use tests as a design tool. Starting from simple requirements, you’ll learn how to express behaviour as tests, build software incrementally, and create designs that are easier to understand, modify, and maintain.

Along the way, you’ll learn practical techniques used by professional Go developers to write tests that are comprehensive, reliable, and genuinely useful.

What will I learn?

You’ll learn both the mechanics of testing in Go and the mindset that makes tests valuable. Topics include:

  • Fundamentals: the testing package, writing and running tests, assertions, comparisons, and readable diffs
  • Design skills: capturing requirements as tests, test-driven development, and designing for clarity and maintainability
  • Error handling: custom errors, wrapping, chaining, sentinel errors, and testing error behaviour
  • Practical techniques: table tests, helpers, test data, temporary files and directories, golden files, and portability
  • Advanced tools: fuzzing, mutation testing, testscript, and coverage analysis
  • Managing dependencies: dependency injection, mocks, fakes, stubs, adapters, and decoupled designs
  • Troubleshooting: flaky tests, slow test suites, missing coverage, and working safely with legacy code

Can I see a preview?

What do I get?

  • PDF and ePub included
  • Works on computers, tablets, phones, and ebook readers

Updates

  • Free lifetime updates
  • Regularly updated for new Go versions

Joanna Liana, Senior Software Engineer, Kashimi

“A great read.”

I'd go as far as to say it's a treasure trove of knowledge on not just testing, but on software design in general. Best of all, it's completely language agnostic—the tips would be relevant to programmers of any mainstream language, not only Gophers. And just like all John’s writing, it's super clear and easy to understand.

Giuseppe Maxia, Software Explorer, VMWare

“Brilliant.”

I read it with genuine pleasure. Well written, clear, concise, and effective.

Andrew Culclasure, DevOps Team Lead, Infor

“This book was AWESOME.”

It answered so many questions that I’ve had.