Skip to Content
Go in Action
book

Go in Action

by Brian Ketelsen, Erik St. Martin, William Kennedy
November 2015
Intermediate to advanced
264 pages
7h 30m
English
Manning Publications
Content preview from Go in Action

Chapter 9. Testing and benchmarking

In this chapter

  • Writing unit tests to validate your code
  • Mocking HTTP-based requests and responses using httptest
  • Documenting your packages with example code
  • Examining performance with benchmarks

Testing your code is not something that you should wait to do until after you’re finished developing your program. With Go’s testing framework, unit testing and benchmarking can happen during the development process. Just like the go build command, there’s a go test command to execute explicit test code that you write. All you need to do is follow a few guidelines, and you can integrate tests into your project and continuous integration systems seamlessly.

9.1. Unit testing

A unit test is a function that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Head First Go

Head First Go

Jay McGavren
Learning Go

Learning Go

Jon Bodner
Head First Git

Head First Git

Raju Gandhi

Publisher Resources

ISBN: 9781617291784Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link