Documentation Home
The MySQL Test Framework, Version 2.0
Download this Manual
PDF (US Ltr) - 0.5Mb
PDF (A4) - 0.5Mb
EPUB - 129.3Kb


The MySQL Test Framework, Version 2.0  /  ...  /  File Naming and Organization Guidelines

4.2.1 File Naming and Organization Guidelines

Test case file names may use alphanumeric characters (A-Z, a-z, 0-9), underscore ('_') or dash ('-'), but should not start with underscore or dash. Other special characters may work but this is not guaranteed so they should be avoided.

Test names have traditionally used lowercase only, and we recommend continuing this for tests added to the common repository, though uppercase letters are also supported.

Test cases are located in the mysql-test/t directory. Test case file names consist of the test name with a .test suffix. For example, a test named foo should be written in the file mysql-test/t/foo.test.

In addition to this directory, tests are organized in test suites, located in subdirectories under the suite directory. For example, a test named bar under the replication suite rpl may be stored in the file mysql-test/suite/rpl/t/bar.test.

In practice, the file would likely be called rpl_bar.test as tests in a suite usually also have the suite name as a prefix. This is just a convention from the time when suites were not supported, and not a requirement for test naming.

One test case file can be a collection of individual tests that belong together. If one of the tests fails, the entire test case fails. Although it may be tempting to write each small test into a single file, that will be too inefficient and makes test runs unbearably slow. So make the test case files not too big, not too small.

Each test case (that is, each test file) must be self contained and independent of other test cases. Do not create or populate a table in one test case and depend on the table in a later test case. If you have some common initialization that needs to be done for multiple test cases, create an include file. That is, create a file containing the initialization code in the mysq-test/include directory, and then put a source command in each test case that requires the code. For example, if several test cases need to have a given table created and filled with data, put the statements to do that in a file named mysql-test/include/create_my_table.inc. The .inc is a convention, not a requirement. Then put the following command in each test case file that needs the initialization code:

--source include/create_my_table.inc

The file name in the source command is relative to the mysql-test directory. Remember to drop the table at the end of each test that creates it.