The basic principle of test case evaluation is that output resulting from running a test case is compared to the expected result. This is just a diff comparison between the output and an expected-result file that the test writer provides. This simplistic method of comparison does not by itself provide any way to handle variation in the output that may occur when a test is run at different times. However, the test language provides commands for postprocessing result output before the comparison occurs. This enables you to manage certain forms of expected variation.
Use the following procedure to write a new test case. In the
test_name represents the name
of the test case. It is assumed here that you'll be using a
development source tree, so that when you create a new test case,
you can commit the files associated with it to the source
repository for others to use.
Change location to the test directory
mysql-represents the root directory of your source tree, such as
Create an empty result file:
Run the test:
Assuming that the test case produces output, it should fail because the output does not match the result file (which is empty at this point). The failure results in creation of a reject file named
r/. Examine this file. If the reject file appears to contain the output that you expect the test case to produce, copy its content to the result file:
Another way to create the result file is by invoking mysql-test-run.pl with the
--recordoption to record the test output in the result file:
Run the test again. This time it should succeed:
You can also run the newly created test case as part of the entire suite:
It is also possible to invoke the mysqltest program directly. If the test case file refers to environment variables, you will need to define those variables in your environment first. For more information about the mysqltest program, see Section 5.1, “mysqltest — Program to Run Test Cases”.