11 Testing
This chapter covers
- Categorizing tests and making them more robust
- Making Go tests deterministic
- Working with utility packages such as
httptest
andiotest
- Avoiding common benchmark mistakes
- Improving the testing process
Testing is a crucial aspect of a project’s lifecycle. It offers countless benefits, such as building confidence in an application, acting as code documentation, and making refactoring easier. Compared to some other languages, Go has strong primitives for writing tests. Throughout this chapter, we look at common mistakes that make the testing process brittle, less effective, and less accurate.
11.1 #82: Not categorizing tests
The testing pyramid is a model that groups tests into different categories (see figure 11.1). ...
Get 100 Go Mistakes and How to Avoid Them 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.