MySQL 8.0.30
Source Code Documentation
Unit Testing Using the Google Test Framework

The Google Test unit-testing framework is available in MySQL source trees and distributions.

Google Test, like MyTAP, provides a unit- testing framework, but Google Test provides richer functionality, such as:

  • A rich set of predicates
  • User-defined predicates and assertions
  • Automatic test registration
  • Nice error reporting when a predicate fails (with line number, expected and actual values, and additional comments)
  • Test fixtures, and setup/teardown logic
  • Death tests
  • Disabled tests
  • Test filtering and shuffling

Google Test runs on many platforms. Some functionality is missing on some platforms (such as death tests and parameterized tests), so those features should not be used.

This section provides notes about using Google Test within the context of MySQL development. For general-purpose information about Google Test, see these resources:

Writing Unit Tests for Google Test

Most of The Google Test unit test files are located in the unittest/gunit directory. You can look at these files to see how tests are written. Here are some examples:

  • sql_list-t.cc: A simple test of some list classes
  • mdl-t.cc: Some tests of metadata locking (MDL), including testing of lock acquisition from multiple threads
  • mdl_mytap-t.cc: The same tests as mdl-t.cc, but written for MyTAP, to illustrate some features of Google Test

Most MyTAP-based tests are likely easily converted to Google Test. However, there might be low-level tests that absolutely must be run on every platform, and thus require MyTAP.

To see what options are available, run a test executable with the --help option.