Building Efficient Test Suites
In the previous chapter, we learned how to supplement the functionality of Go’s testing
package with third-party libraries. These libraries make it easier to mock the dependencies of the Unit Under Test (UUT) and create assertions in these tests. Mocks are essential building blocks to being able to easily write test code for well-designed implementation code, according to the SOLID design principles.
In practice, developers identify edge cases of their requirements and implementations, ensuring a good code coverage percentage, which we discussed in Chapter 2, Unit Testing Essentials. In this chapter, we will learn how to create test suites.
One popular technique for constructing test suites in Go is table-driven testing. We will learn how to build tables that cover edge cases and exercise the UUT with a variety of inputs, ensuring that the UUT has a stable implementation. We will also leverage some of the techniques we’ve explored...