MySQL 9.1.0
Source Code Documentation
Unit Testing Using TAP

The unit-testing facility based on the Test Anything Protocol (TAP) is mainly used when developing Perl and PHP modules.

To write unit tests for C/C++ code, MySQL has developed a library for generating TAP output from C/C++ files. Each unit test is written as a separate source file that is compiled to produce an executable. For the unit test to be recognized as a unit test, the executable file has to be of the format mytext-t. For example, you can create a source file named mytest-t.c that compiles to produce an executable mytest-t. The executable will be found and run when you execute make test or make test-unit in the distribution top-level directory.

Example unit tests can be found in the unittest/examples directory of a MySQL source distribution. The code for the MyTAP protocol is located in the unittest/mytap directory.

Each unit test file should be stored in a storage engine or plugin directory (storage/engine_name or plugin/plugin_name), or one of its subdirectories. A reasonable convention is to create a unittest subdirectory under the storage engine or plugin directory and create unit test files in unittest.