Testing asynchronous code
Finally, let’s explore some techniques to test asynchronous code. The examples shown in this section need GoogleTest and GoogleTest Mock (gMock) libraries to compile. If you are unfamiliar with these libraries, please check the official documentation on how to install and use them.
As we know, unit testing is the practice of writing small and isolated tests that verify the functionality and behavior of a single unit of code. Unit testing helps to find and fix bugs, refactor and improve your code quality, document and communicate the underlying code design, and facilitate collaboration and integration.
This section will not cover the best way to group tests into logical and descriptive suites, or when you should use assertions or expectations to verify the values of different variables and tested methods outcomes. The purpose of this section is to provide some guidelines on how to create unit tests to test asynchronous code. Therefore, some previous...