The Qt framework provides Qt Test, a complete API to create your unit tests in C++. A test executes the code of your application and performs verification on it. Usually, a test compares a variable with an expected value. If the variable does not match the specific value, the test fails. If you wish to go further, you can benchmark your code and get the time/CPU tick/events required by your code. Clicking over and over on a GUI to test it can quickly become boring. Qt Test offers you the possibility to simulate keyboard entries and mouse events on your widgets to completely check your software.
In our case, we want to create a unit test program named drum-machine-test. This console application will check the code of our famous drum machine from the previous chapter. Create a subdirs project, called ch12-drum-machine-test, with the following topology:
- drum...