Testing
Developing production-grade APIs begins with writing comprehensive tests to ensure that the business requirements are met while also verifying the API’s consistency and performance. The first part is mostly handled in unit and integration tests and the second part with load testing.
In the first part of this section, we are going to focus on unit testing the server. We are going to do one test per API type to understand how you can introduce more in the future. In the second part, we are going to introduce ghz, which is a tool for load testing gRPC APIs. We are going to introduce the different options that the tool has and how to load test an API with credentials, an auth token as a header, and so on.
Unit testing
As mentioned, we are going to focus on unit testing the server. Before beginning, it is important to know that the tests presented here are not all the possible tests that we could do. To keep this book readable, I will be presenting how to write unit...